ZF-2695: Select with Array broken with new implementation


Using the old array input with only one qualifier the values have to be seperated with "," to fit in an IN statement.

This has worked in incubator but somehow the code has only be integrated partitionaly...

 $select->where(' IN(?)', array(1, 2, 3));

// Output should be : 
// IN('1','2','3')


Is this really critical enough to hold up the 1.5 release? If not, then we should mark it as a should have.

Not sure... This is a possible BC problem between 1.0.4 and 1.5.

Better to ask Simon or Bill about possible implications.

So... I added array handling for values (not for conditions this is another issue).

But there is still a problem as only numbers (ints/floats) are quoted, and strings not. This problem is another one than this... but it is the reason why array values are not working for strings and should also be fixed.

I will keep this issue open until also strings are working for array notation in values.

Reproducable code

$select = new Zend_Db_Select($database);
       ->where("name IN (?)", array(2, 6));

print "\nIntegerARRAY:".$select;

$select = new Zend_Db_Select($database);
       ->where("name IN (?)", array('2', '6'));

print "\nString ARRAY:".$select;

The first produces name IN (2, 6) But the second produces name IN (, ) but it should be name IN ('2', '6')

Class will be reworked by Simon... He has a better overview over the complete Db design, not only Zend_Db_Select and will fix this better than me.

Hello, After you last commit (8711) i have problem with findDependentRowset() method. When i use it i get error:

Fatal error: Uncaught exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[21000]: 
Cardinality violation: 1241 Operand should contain 1 column(s)' in C:\wamp\www\libs\Zend\Db\Statement\Pdo.php:238 
Stack trace: #0 C:\wamp\www\libs\Zend\Db\Statement.php(283): Zend_Db_Statement_Pdo->_execute(Array) #1 
C:\wamp\www\libs\Zend\Db\Adapter\Abstract.php(406): Zend_Db_Statement->execute(Array) #2 
C:\wamp\www\libs\Zend\Db\Adapter\Pdo\Abstract.php(206): Zend_Db_Adapter_Abstract->query(Object(Zend_Db_Table_Select), Array) #3 
C:\wamp\www\libs\Zend\Db\Table\Abstract.php(1185): Zend_Db_Adapter_Pdo_Abstract->query(Object(Zend_Db_Table_Select)) #4 
C:\wamp\www\libs\Zend\Db\Table\Abstract.php(1040): Zend_Db_Table_Abstract->_fetch(Object(Zend_Db_Table_Select)) #5 
C:\wamp\www\libs\Zend\Db\Table\Row\Abstract.php(839): Zend_Db_Table_Abstract->fetchAll(Object(Zend_Db_Table_Select)) #6 
C:\wamp\www\dev\app\controllers\BazaController.php(34): Zend_Db_Table_Row_Abstract->findDependentRowset('Bugs') #7 
C:\wamp\www\libs\Zend\Controller\Action. in C:\wamp\www\libs\Zend\Db\Statement\Pdo.php on line 238

I check it on examples from manual… . Relationshitp: $bugsReportedByUser = $user1234->findDependentRowset('Bugs');

Resolved in trunk r8783

I'm assuming this was merged to the 1.5 release branch for the 1.5.0 release. Please update JIRA if this is not the case.