MeuMySQL Blog is now at http://blog.mdnsolutions.com/.
Showing posts with label Doctrine. Show all posts
Showing posts with label Doctrine. Show all posts

Saturday, October 20, 2012

FAQ Symfony - Dicas Quentes

Salve galera! Venho fazendo teste e projetos em Symfony e gostaria de compartilhar algumas, dicas, curiosidades e dúvidas que tenho tido. Bem, este tópico é 'endless' e vou incrementando ele conforme descubra mais novidades, espero que sejam úteis para vocês também. E qualquer outra dúvida, por favor comentar.


Tuesday, October 9, 2012

[en] Doctrine, specifying Null values


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!