Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Trivial
-
Resolution: Fixed
-
Affects Version/s: 1.5.1
-
Fix Version/s: 1.9.3
-
Component/s: Zend_Db_Table
-
Labels:None
-
Fix Version Priority:Nice to Have
Description
API Doc says that .find() method accepts arrays of arguments (one per primary key field), but it does not specify that these arrays MUST NOT be hash, otherwise array entries are skipped and .find() does not return all matching rows!
Very serious bug!
Ex: $id = array(0=>1, 1=>2, 99=>3);
mytable.find($id) will skip value '3' because its key is not 2.
Generated $whereClause is:
((`id` = 1) OR (`id` = 2) OR (`id` = 0))
where expected clause is:
((`id` = 1) OR (`id` = 2) OR (`id` = 3))
This comes from the following code, in Zend_Db_Table_Abstract, public function find():
for ($i = 0; $i < count($keyValues); ++$i) {
$whereList[$i][$keyPosition] = $keyValues[$i];
}
which could be replaced by:
$i = 0;
foreach ($keyValues as $v) {
$whereList[$i++][$keyPosition] = $v;
}
Great framework anyway!
Keep up, guys!
Thx
Issue Links
| This issue is duplicated by: | ||||
| ZF-7653 | get unexpected result from find() function if passed an array within dis-ordered key |
|
|
|
The arguments array provide to find() need no keys.
So , I think , a better way is to use array_values() in find() method to evevy arguments array, make sure they all index by 0 , 1 , 2 .....