QueryBuilder.php 878 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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\AdminBundle\Tests\Filter\ORM;
  11. use Sonata\AdminBundle\Filter\ORM\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. }