I have such a query:
$thism = new \DateTime('first day of this month midnight');
$parameters = array('thism' => $thism, 'user' => $user,'status'=>1);
->where('q.createdAt > :thism')
->andWhere('q.user = :user')
->andWhere('q.completed != :status')
q.completed != :status
* @var boolean
* @ORM\Column(name="completed", type="boolean", nullable=true)
Null in MySQL is not the same as true or false. More info on that on MySQL official site.
Your query in translation to SQL will be:
SELECT count(1) FROM <some table> WHERE completed != 1 AND createdAt > '01042016 00:00' AND user = 'some_user'
If you want to query for null values too in SQL you should have a query such as:
SELECT count(1) FROM <some table> WHERE ( completed != 1 or completed is NULL) AND createdAt > '01042016 00:00' AND user = 'some_user'
If you need this column by default to have some value - you can define it in MySQL by using
default 0 (or any other value) in your
CREATE TABLE statement like that:
CREATE TABLE my_table( ... completed tinyint(1) default 0 .... )
If you do that - your query should work with no change.