开发者

Doctrine_Record doesn't set PK in object after save()

Per documentation, Doctrine_Record after saving should set id of newly created record as object property. In my case, new record is created, but not value is set on object (whi开发者_如何学编程le database has this new id value). What has caused this?

$user1 = new ModelUsers();
$user1->save();
echo "last insert id=" . $user1->UserId;

PS UserId is configured in Model class with 'primary' => true, 'autoincrement' => true


You are using camel case syntax, which is used to access related items as in :

$object->Related->getId();

When accessing a Doctrine_Record properties, you should use one of those syntaxes :

$object['user_id'];
$object->getUserId();
$object->user_id; // note that this is NOT camel case, but lowercase with underscores
$object->get('user_id');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜