My database table looks like this;
id name
---------
1 Open
2 On Hold
3 Closed
the result i want is an associative array like this;
array(1 => 'Open', 2 => 'On hold', 3 => 'Closed');
I can't find any simple way to return these results from doctine, so I'm using this code;
$query = $this->em->createQuery("SELECT s FROM Project\Entity\ProjectStatus s");
$statuses = $query->getResult();
$result = array();
foreach($statuses as $status)
{
$result[$status->getId()] = $status->getName();
}
return $result;
This feels long winded. Is there a simpler way? I've tried Query::HYDRATE_ARRAY but it still includes the field names in the resulting array. I just wan't the values.