nciri / zend-db-model-generator

Automatically exported from code.google.com/p/zend-db-model-generator
0 stars 0 forks source link

0.7 RC1 fetchList() with null WHERE throws an exception #24

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. $document = new App_Model_Mapper_Document();
2. $document->fetchList(null, 'DocumentTypeID'); //only ORDER BY
3. Exception thrown in models/DbTable/TableAbstract.php:146
App_Model_DbTable_TableAbstract->fetchList(Array, 'DocumentTypeID', NULL, NULL) 
with message: "You must pass integer indexes on the select statement array."

What is the expected output? What do you see instead?
Select runs with only an ORDER BY fetching all rows.

What version of the product are you using? On what operating system?
0.7 RC 1 (this is a regression)

Please provide any additional information below.

Original issue reported on code.google.com by szots...@gmail.com on 18 Jun 2012 at 10:10

GoogleCodeExporter commented 8 years ago
Try using array() instead of null, that should work

Original comment by pedrospdc on 26 Jun 2012 at 2:48

GoogleCodeExporter commented 8 years ago

Original comment by pedrospdc on 26 Jun 2012 at 2:49

GoogleCodeExporter commented 8 years ago
If I remember well, that doesn't work either because of the "&& 
isset($where[0])" condition.

And as I can see without trying it, the function countByQuery() (right up 
there) also suffers from the empty/default $where bug.

Original comment by szots...@gmail.com on 26 Jun 2012 at 3:02

GoogleCodeExporter commented 8 years ago
Indeed, those come from the changes I've made on 0.7. I'll work on the fix asap.

Thanks!

Original comment by pedrospdc on 26 Jun 2012 at 3:03

GoogleCodeExporter commented 8 years ago
TableAbstract.php, return early if $where is empty

public function fetchList($where = null, $order = null, $count = null, $offset 
= null)
    {
        $select = $this->select()
                    ->order($order)
                    ->limit($count, $offset);

        if (empty($where))
            return $select;

        if (! empty($where) && is_string($where))

Original comment by diegot...@gmail.com on 3 Sep 2012 at 3:05

GoogleCodeExporter commented 8 years ago
Hello,

Is there a patch available for this?

Original comment by Aa...@theaudience.com on 21 Sep 2012 at 5:50

GoogleCodeExporter commented 8 years ago
Hello Aaron,
Due to some "madness", "apocalypse" or even "bad things" happening at my work 
place I've been really really busy for the past months. 
You can use diegotdai's suggestion - just manually edit 
classes/TableAbstract.php function and generate the models again, then replace 
your old TableAbstract.php model at your project models folder. (No need to 
replace every model)

I'll work on an patch until then

Original comment by pedrospdc on 21 Sep 2012 at 7:00

GoogleCodeExporter commented 8 years ago
Precise is a leading brand for Model makers and engineering model makers. With 
our innovative ideas, excellent artisans and specialized materials.

Original comment by precisee...@gmail.com on 8 Nov 2012 at 6:37

GoogleCodeExporter commented 8 years ago
or put 1=1 in where

Original comment by vdvb...@gmail.com on 26 Nov 2012 at 2:07