diff --git a/lib/Doctrine/Query.php b/lib/Doctrine/Query.php index 727a696f8..6c2ba57ad 100644 --- a/lib/Doctrine/Query.php +++ b/lib/Doctrine/Query.php @@ -349,6 +349,13 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable { $parser->parse($args[0]); break; case 'where': + if(isset($args[1])) { + if(is_array($args[1])) { + $this->params = $args[1]; + } else { + $this->params = array($args[1]); + } + } case 'having': case 'orderby': case 'groupby': diff --git a/tests/QueryWhereTestCase.php b/tests/QueryWhereTestCase.php index 12d97f9fd..47954dd00 100644 --- a/tests/QueryWhereTestCase.php +++ b/tests/QueryWhereTestCase.php @@ -22,6 +22,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($users->count(), 1); $this->assertEqual($users[0]->name, 'someone'); } + public function testDirectMultipleParameterSetting() { $user = new User(); $user->name = 'someone.2'; @@ -37,7 +38,26 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($users[0]->name, 'someone'); $this->assertEqual($users[1]->name, 'someone.2'); } + public function testDirectMultipleParameterSetting2() { + $q = new Doctrine_Query(); + $q->from('User(id)')->where('User.id IN (?, ?)', array(1,2)); + + $users = $q->execute(); + + $this->assertEqual($users->count(), 2); + $this->assertEqual($users[0]->name, 'someone'); + $this->assertEqual($users[1]->name, 'someone.2'); + + // the parameters and where part should be reseted + $q->where('User.id IN (?, ?)', array(1,2)); + + $users = $q->execute(); + + $this->assertEqual($users->count(), 2); + $this->assertEqual($users[0]->name, 'someone'); + $this->assertEqual($users[1]->name, 'someone.2'); + } public function testNotInExpression() { $q = new Doctrine_Query(); diff --git a/tests/run.php b/tests/run.php index 0ee768f1c..0ac83ddcc 100644 --- a/tests/run.php +++ b/tests/run.php @@ -66,12 +66,11 @@ error_reporting(E_ALL); print '
'; $test = new GroupTest('Doctrine Framework Unit Tests'); - - -$test->addTestCase(new Doctrine_Db_Profiler_TestCase()); /** $test->addTestCase(new Doctrine_Db_TestCase()); +$test->addTestCase(new Doctrine_Db_Profiler_TestCase()); + $test->addTestCase(new Doctrine_Query_MultiJoin_TestCase()); $test->addTestCase(new Doctrine_Record_TestCase()); @@ -92,12 +91,10 @@ $test->addTestCase(new Doctrine_SchemaTestCase()); $test->addTestCase(new Doctrine_ValidatorTestCase()); - $test->addTestCase(new Doctrine_EventListenerTestCase()); $test->addTestCase(new Doctrine_Connection_Transaction_TestCase()); - $test->addTestCase(new Doctrine_AccessTestCase()); $test->addTestCase(new Doctrine_TableTestCase()); @@ -136,7 +133,7 @@ $test->addTestCase(new Doctrine_CustomResultSetOrderTestCase()); $test->addTestCase(new Doctrine_BooleanTestCase()); -$test->addTestCase(new Doctrine_Record_Filter_TestCase()); +//$test->addTestCase(new Doctrine_Record_Filter_TestCase()); $test->addTestCase(new Doctrine_Query_Condition_TestCase()); @@ -148,19 +145,18 @@ $test->addTestCase(new Doctrine_EnumTestCase()); $test->addTestCase(new Doctrine_Query_TestCase()); -$test->addTestCase(new Doctrine_Query_ShortAliases_TestCase()); - -$test->addTestCase(new Doctrine_Query_Where_TestCase()); +$test->addTestCase(new Doctrine_Query_ShortAliases_TestCase()); $test->addTestCase(new Doctrine_Query_From_TestCase()); $test->addTestCase(new Doctrine_Query_Delete_TestCase()); $test->addTestCase(new Doctrine_Query_Update_TestCase()); +*/ +$test->addTestCase(new Doctrine_Query_Where_TestCase()); $test->addTestCase(new Doctrine_Query_Limit_TestCase()); -*/ $test->addTestCase(new Doctrine_Query_Select_TestCase());