开发者

Object to database with PDO, is it possible?

I'm using PDO's fetch_class feature to retrieve data from my database row into object, It's pretty convenient, but how can I do to do the opposite (开发者_JS百科object to database row) ? without using serialization of course.


without using an ORM, you have to create your own save method.

Bye.


Haven't used PDO before, I assume the fetch's contents are stored as $object->Key?

You'd have to write an update method/function

$sql = "UPDATE `table` SET `fieldone` = '$object->fieldone',`fieldtwo` = '$object->fieldtwo' WHERE `id` = $object->id"

mysql_query($sql);

etc.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜