Symfony Doctrine Execute Raw SQL

Posted Under: Doctrine, PHP, Programming, Symfony, Tutorials on Jan 10, 2011
Converting to object oriented can be sometimes difficult as people are not used to it... same is the case with ORM, when you use it there may be some problems for the new comers. Doctrine an ORM tool, can execute Raw SQL queries beside fully object and partial queries, executing raw sql queries is very simple following PHP code demonstrate it, here we use Doctrine with symfony.
public function executeShowUserInfo(sfWebRequest $request){

     $query = Doctrine_Query::create()
      ->query("select * from user");

     $result = $query->toArray();

     $count = count($result);


         echo $result [$i]["first_name"]
         ." => "
         .$result [$i]["email"]

here $query->toArray() convert returned response in to array.
Note : it is not recommended to echo from a controller, i do it just for demonstration purpose.
© Tutorial Jinni