Hi guys! I'd like to share a doubt I had other day here about using Doctrine queries. I was trying to write a query to return only records with a certain null value column, to do so all you need to do is something like below:
$query = Doctrine_Query::create()
->select('t1.*')
->from('entityName t1')
->where('t1.columnName is NULL');
$resultSet = $query->execute(array(), Doctrine::HYDRATE_ARRAY);
Easy and simple. Works the same way for both DQLs and queries in Doctrine.
$dql = $entityManager->createQueryBuilder()
->select('t')
->from('ns:Entity', 't')
->where('t.columnName is NULL ');
$arrayOfData = $dql->getQuery()->execute();
Enjoy!
No comments:
Post a Comment