开发者

How to update a dataset by an doctrine object?

I've been working with Doctrine a while now, but I'm not very happy with it.

I try to do following: (the Primary Key of the User Table is an autoincement with name userID)

$user = new Mode_User();
$user->set('username', 'BenKenobi');
$user->save();

it works OK and Doctrine saves it to the database. Now I want i开发者_开发技巧t to update this object by do this:

$user->set('email', 'BenKenobi@etc.de');
$user->save();

This will throw no error but nothing happens. Does someone has a tipp for me beacuse that is the way a ORM should work.


(I assume you are using Doctrine 1.x)

I suggest that you read the fine docs for Doctrine and work through its examples.

What you want is similar to this:

$user = new Mode_User();
$user->username = 'BenKenobi;
$user->email = 'BenKenobi@etc.de';
$user->save();

You don't use set explicitly but you set the value for a property of the model. Of course all this functionallity depends on a proper set up in the database and that you set all of the models properties accordingly.


Yes we are using Doctrine 1.2. And i found the problem. Ther is an preUpdate()-Method in the User-Model. When i comment the method out then everything functions but with this method not. I decided to make a query an execute it.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜