OK. I must be missing something very simple here. I just want to return all the records from the table where user_id matches (easy!) And the fields are "paid", either NULL, or 0. In my paid field there is TinyInt (1).
The code for my CakePHP model is:
$workingRecord = $this->find('first',array( 'conditions'=>array( 'Subscription.user_id'=>$userId, array('not' => array('Subscription.paid' => true))
CakePHP generated SQL looks like this:
SELECT `Subscription`.`id`, `Subscription`.`paid` FROM `subscriptions` AS `Subscription` WHERE `Subscription`.`user_id` = 3 AND NOT (`Subscription`.`paid` = '1') LIMIT 1
Common sense would say that this should work. The problem is that SQL will return rows containing 0 in the paid column, but will never return NULL.
Is there a way to return zero and NULL in one clock cycle without using 'or'?
Thanks in advance.
source share