Commit 74af8a28 authored by guilhermeblanco's avatar guilhermeblanco

[2.0] Removed *where*In methods from QueryBuilder. Finished decouple of...

[2.0] Removed *where*In methods from QueryBuilder. Finished decouple of QueryBuilder and Expr. Updated docs.
parent 842267c1
......@@ -27,15 +27,13 @@ use Doctrine\ORM\Query\Expr;
* This class is responsible for building DQL query strings via an object oriented
* PHP interface.
*
* TODO: I don't like the API of using the Expr::*() syntax inside of the QueryBuilder
* methods. What can we do to allow them to do it more fluently with the QueryBuilder.
*
* @author Jonathan H. Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.doctrine-project.org
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision$
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
class QueryBuilder
{
......@@ -313,34 +311,14 @@ class QueryBuilder
return $this->add('where', $where);
}
public function andWhereIn($expr, $params)
{
return $this->andWhere(Expr::in($expr, $params));
}
public function orWhereIn($expr, $params = array())
{
return $this->orWhere(Expr::in($expr, $params));
}
public function andWhereNotIn($expr, $params = array())
{
return $this->andWhere(Expr::notIn($expr, $params));
}
public function orWhereNotIn($expr, $params = array())
{
return $this->orWhere(Expr::notIn($expr, $params));
}
public function groupBy($groupBy)
{
return $this->add('groupBy', Expr::groupBy($groupBy), false);
return $this->add('groupBy', new Expr\GroupBy(func_get_args()));
}
public function addGroupBy($groupBy)
{
return $this->add('groupBy', Expr::groupBy($groupBy), true);
return $this->add('groupBy', new Expr\GroupBy(func_get_args()), true);
}
public function having($having)
......@@ -384,12 +362,12 @@ class QueryBuilder
public function orderBy($sort, $order = null)
{
return $this->add('orderBy', Expr::orderBy($sort, $order), false);
return $this->add('orderBy', new Expr\OrderBy($sort, $order));
}
public function addOrderBy($sort, $order = null)
{
return $this->add('orderBy', Expr::orderBy($sort, $order), true);
return $this->add('orderBy', new Expr\OrderBy($sort, $order), true);
}
/**
......
......@@ -187,7 +187,7 @@ class QueryBuilderTest extends \Doctrine\Tests\OrmTestCase
->select('u')
->from('Doctrine\Tests\Models\CMS\CmsUser', 'u')
->where('u.id = :uid')
->andWhereIn('u.id', array(1, 2, 3));
->andWhere(Expr::in('u.id', array(1, 2, 3)));
$this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE (u.id = :uid) AND (u.id IN(1, 2, 3))');
}
......@@ -198,7 +198,7 @@ class QueryBuilderTest extends \Doctrine\Tests\OrmTestCase
->select('u')
->from('Doctrine\Tests\Models\CMS\CmsUser', 'u')
->where('u.id = :uid')
->orWhereIn('u.id', array(1, 2, 3));
->orWhere(Expr::in('u.id', array(1, 2, 3)));
$this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE (u.id = :uid) OR (u.id IN(1, 2, 3))');
}
......@@ -209,7 +209,7 @@ class QueryBuilderTest extends \Doctrine\Tests\OrmTestCase
->select('u')
->from('Doctrine\Tests\Models\CMS\CmsUser', 'u')
->where('u.id = :uid')
->andWhereNotIn('u.id', array(1, 2, 3));
->andWhere(Expr::notIn('u.id', array(1, 2, 3)));
$this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE (u.id = :uid) AND (u.id NOT IN(1, 2, 3))');
}
......@@ -220,7 +220,7 @@ class QueryBuilderTest extends \Doctrine\Tests\OrmTestCase
->select('u')
->from('Doctrine\Tests\Models\CMS\CmsUser', 'u')
->where('u.id = :uid')
->OrWhereNotIn('u.id', array(1, 2, 3));
->OrWhere(Expr::notIn('u.id', array(1, 2, 3)));
$this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE (u.id = :uid) OR (u.id NOT IN(1, 2, 3))');
}
......
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