you can use
$q->fetchOne()
to retrieve a single record (object) or
$q->excute()
to get a group of objects.
I use them almost every time I use symfony. sometimes you need to take arrays, in which case you can use data hydration, for example HYDRATE_ARRAY or HYDRATE_ARRAY_HIERARCHY, if you have a nested set.
Regarding raw queries, check this out: raw sql in the doctrine
Edit:
I just needed to use raw requests, and here is how it works in symfony:
$pdo = Doctrine_Manager::getInstance()->getCurrentConnection()->getDbh(); $query = "SELECT name, slug, ( 3959 * acos( cos( radians(:lat) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( lat ) ) ) ) AS distance FROM rss_city WHERE (lat <> :lat and lng <> :lng)HAVING distance IS NOT NULL ORDER BY distance LIMIT 5"; $stmt = $pdo->prepare($query); $params = array( "lat" => $lat, "lng" => $lng ); $stmt->execute($params); $results = $stmt->fetchAll();
This query returns an array of the 5 nearest cities to our lat / lng coordinates. I think this is self-evident.
source share