SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'and ci_activity = 1 and ci_deleted = 0 and (cr_deleted = 0 or cr' at line 4 The SQL being executed was: select * from calltracking.campaign_info left join ct_rules cr on campaign_info.ci_id = cr.cr_campaign_id left join pt_main pm on cr.cr_condition = pm.pt_id where ci_user_id = and ci_activity = 1 and ci_deleted = 0 and (cr_deleted = 0 or cr_deleted is null) order by ci_priority, cr_priority