$result = $this->er->createQueryBuilder("r")
->select("COUNT(r.customer IS NOT NULL) as customers")
->getQuery()
->getResult(AbstractQuery::HYDRATE_ARRAY);
I'm trying to run this query using Doctrine Query Builder but it returns this error: Doctrine\ORM\Query\QueryException [Semantical Error] ...: Error: Class 'NULL' is not defined. when using NULL
What am I doing wrong? How can I implement IS NOT NULL
into my query?
EDIT
Also, please consider this:
$result = $this->er->createQueryBuilder("r")
->select(
"COUNT(r.customer) as customers_total",
"COUNT(r.customer IS NOT NULL) as customers_set",
"COUNT(r.customer IS NULL) as customers_unset"
)
->getQuery()
->getResult(AbstractQuery::HYDRATE_ARRAY);
Therefore, adding ->where("r.customer IS NOT NULL")
would't work much here. My first question wasn't defined precisely. I'm sorry about that.