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.
精彩评论