Quantcast
Channel: Select One column Doctrine DQL - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by Julien Lamarche for Select One column Doctrine DQL

$
0
0

I'm not sure what version of Doctrine j0k was using. It provided some answers, but I did have trouble finding Doctrine_Query and Doctrine_Core classes. I am using Doctrine 2.3.4. The following worked for me.

public static function getAllEventIDs($em) {    return parent::getAllFromColumn('\path\to\Entity\entityName', 'id', $em);}public static function getAllFromColumn($tableName, $columnName, $em) {    $q = $em->createQueryBuilder('t')    ->select("t.$columnName")    ->from($tableName, 't');    $q = $q->getQuery();    $result = $q->getResult(\Doctrine\ORM\Query::HYDRATE_SCALAR);    return $result;}

This did however return a array of arrays. ie, the id of the first event was is

$result[0]['id'];

Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>