QueryBuilder.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /*
  3. * This file is part of the Sonata package.
  4. *
  5. * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Sonata\DoctrineORMAdminBundle\Tests\Filter;
  11. use Sonata\DoctrineORMAdminBundle\Filter\Filter;
  12. class QueryBuilder
  13. {
  14. public $parameters = array();
  15. public $query = array();
  16. public function setParameter($name, $value)
  17. {
  18. $this->parameters[$name] = $value;
  19. }
  20. public function andWhere($query)
  21. {
  22. $this->query[] = $query;
  23. }
  24. public function expr()
  25. {
  26. return $this;
  27. }
  28. public function in($name, $value)
  29. {
  30. $this->query[] = 'in_'.$name;
  31. $this->parameters[] = 'in_'.$value;
  32. return sprintf('%s IN ("%s")', $name, implode(',', $value));
  33. }
  34. public function getRootAlias()
  35. {
  36. return 'o';
  37. }
  38. public function leftJoin($parameter, $alias)
  39. {
  40. $this->query[] = $parameter;
  41. }
  42. }