I have Table 
Categories_Products
{
   cat_id int
   prod_id int
   primary key (cat_id, prod_id)
}

and the class:

class Prodcat extends Zend_Db_Table  {

    protected $_name = 'Categories_Products';
    protected $_primary = array("prod_id", "cat_id");
.....
    
or without "protected $_primary", no diffrence.

And now when I'm going to 
        $pc = new Prodcat();
        $where = $pc->getAdapter()->quoteInto("cat_id IN (?)", explode("|",
$list));
        $temp = $pc->fetchAll($where);


if THERE'S RECORDS FOUND IT'S GOOD, no problem, everything is working
excelent, but if there is NOT matching record in my database (there is no
records with cat_id from list) I got very bad error. 

I will write AGAIN, the error is ONLY when no records found.

Very bad error:
Fatal error: Uncaught exception 'Zend_Db_Statement_Exception' with message
'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 '))' at line 1' in
D:\progs\VertrigoServ\www\cudny\library\Zend\Db\Statement\Pdo.php:238 Stack
trace: #0
D:\progs\VertrigoServ\www\cudny\library\Zend\Db\Statement.php(283):
Zend_Db_Statement_Pdo->_execute(Array) #1
D:\progs\VertrigoServ\www\cudny\library\Zend\Db\Adapter\Abstract.php(430):
Zend_Db_Statement->execute(Array) #2
D:\progs\VertrigoServ\www\cudny\library\Zend\Db\Adapter\Pdo\Abstract.php(220):
Zend_Db_Adapter_Abstract->query(Object(Zend_Db_Table_Select), Array) #3
D:\progs\VertrigoServ\www\cudny\library\Zend\Db\Table\Abstract.php(1330):
Zend_Db_Adapter_Pdo_Abstract->query(Object(Zend_Db_Table_Select)) #4
D:\progs\VertrigoServ\www\cudny\library\Zend\Db\Table\Abstract.php(1158):
Zend_Db_Table_Abstract->_fetch(Object(Zend_Db_Table_Select)) #5 D:\progs\Ver
in D:\progs\VertrigoServ\www\cudny\library\Zend\Db\Statement\Pdo.php on line
238


What can I do ? Can anyone help ? Can anyone know why it happen ?
-- 
View this message in context: 
http://www.nabble.com/Problem-with-fetchAll-of-Table-with-Primary-Keys-as-pair-tp21670110p21670110.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to