Sometimes you have situation which require writing of native SQL query in project fully based on Doctrine ORM. Doing DQL queries is very easy, but simple SQL queries maybe difficult to execute because you have to reuse database connection opened inside Doctrine.
Example given below is easy to understand and use in your project(s). Enjoy!// get Doctrine_Connection object
$con = Doctrine_Manager::getInstance()->connection();
// execute SQL query, receive Doctrine_Connection_Statement
$st = $con->execute("...............");
// fetch query result
$result = $st->fetchAll();
4 comments:
Thanks man, you saved my life!!!
Thanks a lot. Doctrine's documentation is not very good. Ive been looking for this for a couple of day.
Great job!But I need to get dataset as Doctrine_Query Object.How can I do that?
okan, I think you can do the following. For each array in the result set: create your object manually (like $user = new User()) and populate it with your data $user->fromArray().
Post a Comment