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); for($i=0;$i<$count;$i++){ 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 just for demonstration purpose.
1 comments:
Thanks a lot. Was trying using the symfony example provided in the manual but it seems to be outdated stuff.
Also, maybe it's me but the Doctrine manual is very hard to understand and follow.
Post a Comment