wriver4 / nanoframework

Automatically exported from code.google.com/p/nanoframework
1 stars 0 forks source link

ModelObject::find and conditions with 'AND' #5

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
AND in conditions should be reversible :

This should work, but it doesn't :

$this->view->projects =
NanoFramework::Database::ModelObject::find('Models::Project', array(
                    'limit' => array(0,50),
                    'conditions' => array(
                        'string' => "theme_id={integer:theme} AND name LIKE
CONCAT('%', {varchar(255):var_1}, '%')",
                        'var_1' => $this->view->q,
                        'theme' => $this->view->theme_id
                    )
                ));                 

But this does :

$this->view->projects =
NanoFramework::Database::ModelObject::find('Models::Project', array(
                    'limit' => array(0,50),
                    'conditions' => array(
                        'string' => "name LIKE CONCAT('%',
{varchar(255):var_1}, '%') AND theme_id={integer:theme}",
                        'var_1' => $this->view->q,
                        'theme' => $this->view->theme_id
                    )
                ));                 

Difference is in the 'conditions' string

Original issue reported on code.google.com by stephane...@gmail.com on 16 Oct 2008 at 9:24

GoogleCodeExporter commented 8 years ago
This is not really a bug : when the find is called, a stored function is 
created by
mysql and the parameter order is fixed that time. 

So we can't call it again with a different parameter order, ... we could but I 
think
it would not be a good solution as we'll spent too much time in re-arranging the
query parameter. There would be no benefits doing that.

Original comment by stephane...@gmail.com on 3 Dec 2009 at 4:00