Commit 34ecd304 authored by zYne's avatar zYne

Doctrine_Query::where() now accepts prepared statement parameters

parent 188520e9
......@@ -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':
......
......@@ -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();
......
......@@ -66,12 +66,11 @@ error_reporting(E_ALL);
print '<pre>';
$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());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment