So here is my code in question:
$notifications = Notifications::model()->findAll('content_author=' . $id . ' AND read =0');
Now to me the SQL looks fine yet its throwing me the following error:
What is going wrong in this statement?
So here is my code in question:
$notifications = Notifications::model()->findAll('content_author=' . $id . ' AND read =0');
Now to me the SQL looks fine yet its throwing me the following error:
What is going wrong in this statement?
Hi,
read is MySQL reserved word, you can read about it here
Wrap ‘read’ by `:
$notifications = Notifications::model()->findAll('content_author=' . $id . ' AND `read` =0');
OR add table prefix:
$notifications = Notifications::model()->findAll('content_author=' . $id . ' AND t.read =0');
OR both :
$notifications = Notifications::model()->findAll('content_author=' . $id . ' AND `t`.`read` =0');
OR:
$notifications = Notifications::model()->findAllByAttributes(array(
'content_author' => $id,
'read' => 0
));
and let the framework take care of the rest.
Thank you very much everyone!