views:

44

answers:

2

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 (while 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

+1  A: 

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');
DuoSRX
A: 

Same problem here. Probably Doctrine bug. What DuoSRX wrote is nonsense. If you use camelCase in database then you also access object properties using camelCase.

Svaistiks