Can PHP PDO extension bind nested objects automatically? I mean using foreign key to bind automagicallymessages array to a collection of Message instances:
class User
{
public $id, $name;
public messages = array();
}
class Message { public $id, $content }
---------------------------- -------------------------------------------
| Table user | id | name | | Table message | id | content | user_id |
---------------------------- -------------------------------------------
No, it can’t. You could write a simple layer on top though that accomplishes that for you. PDO is a database abstraction layer. That means that it provides a consistent API to access multiple kinds of databases. It is not – in any way – an ORM layer. If you want something like that, look at Doctrine or Propel. These will do what you want.