Exemplo n.º 1
0
 /**
  * Perform a query
  *
  * @param string $query
  * @return array
  */
 public function find($query)
 {
     $qb = $this->repository->createQueryBuilder('p');
     $tokens = explode(' ', trim($query));
     foreach ($tokens as $p => $token) {
         $qb->orWhere($qb->expr()->like('p.headline', $qb->expr()->literal("%{$token}%")));
     }
     return $qb->getQuery()->getResult();
 }
Exemplo n.º 2
0
 /**
  * Build where condition
  *
  * @param array $cols
  * @param string $search
  * @return Doctrine\ORM\Query\Expr
  */
 private function buildWhere(array $cols, $search)
 {
     $qb = $this->_repository->createQueryBuilder('e');
     $or = $qb->expr()->orx();
     foreach (array_keys($cols) as $i => $property) {
         if (!is_string($property)) {
             // not searchable
             continue;
         }
         $or->add($qb->expr()->like("e.{$property}", $qb->expr()->literal("%{$search}%")));
     }
     return $or;
 }
Exemplo n.º 3
0
 /**
  * Build where condition
  *
  * @param array $cols
  * @param string $search
  * @return Doctrine\ORM\Query\Expr
  */
 private function buildWhere(array $cols, $params)
 {
     $qb = $this->repository->createQueryBuilder('e');
     $or = $qb->expr()->orx();
     $reflection = new \ReflectionObject(new $this->entityName());
     $search = $params['sSearch'];
     foreach (array_keys($cols) as $id => $property) {
         //column is searchable
         if ($reflection->hasProperty($property) && $params["bSearchable_{$id}"]) {
             $or->add($qb->expr()->like("e.{$property}", $qb->expr()->literal("%{$search}%")));
         }
     }
     return $or;
 }
Exemplo n.º 4
0
 public function __construct($repository)
 {
     $this->repository = $repository;
     $this->queryBuilder = $this->repository->createQueryBuilder(self::DEFAULT_TABLE_ALIAS);
     $this->classMetadata = $this->repository->getClassMetadata();
 }