After performing a custom query using
$DBH = Doctrine_Manager::getInstance()->connection()->getDbh();
$PDO = $DBH->prepare("mysql query");
$PDO->execute();
How do I return model objects instead of record arrays?
开发者_高级运维EDIT
I got mine working by using something like this: $data_object = doctrine_core::getTable('table_name')->find('id_from_raw_SQL')
. Easy as pie! And thanks to Dan for the hint.
I don't think you can automatically with a raw SQL query. You could always write your own hydrate method that creates the objects from the results.
If you want Doctrine to do it, you have to write at least the SELECT portion of the query with certain syntax to use Doctrine_RawSql
and get hydrated objects:
http://www.doctrine-project.org/documentation/manual/1_2/en/native-sql
http://www.doctrine-project.org/api/orm/1.2/doctrine/doctrine_rawsql.html
精彩评论