SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "AND" LINE 7: WHERE i.id = AND i.peri... ^