开发者

Object to database with PDO, is it possible?

开发者 https://www.devze.com 2023-01-31 23:25 出处:网络
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 us

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

精彩评论

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