/**
  * @param QueryBuilder  $queryBuilder
  * @param SortInterface $sort
  * @param Mapping       $mapping
  */
 public static function sort(QueryBuilder $queryBuilder, SortInterface $sort, Mapping $mapping)
 {
     $columns = $mapping->map();
     foreach ($sort->orders() as $propertyName => $order) {
         self::guardColumnExists($columns, $propertyName);
         $queryBuilder->orderBy($columns[$propertyName], $order->isAscending() ? Order::ASCENDING : Order::DESCENDING);
     }
 }
 /**
  * @param QueryBuilder    $query
  * @param FilterInterface $filter
  * @param Mapping         $mapping
  *
  * @return QueryBuilder
  */
 public static function filter(QueryBuilder $query, FilterInterface $filter, Mapping $mapping)
 {
     $placeholders = [];
     $columns = $mapping->map();
     foreach ($filter->filters() as $condition => $filters) {
         $filters = self::removeEmptyFilters($filters);
         if (count($filters) > 0) {
             self::processConditions($columns, $placeholders, $query, $condition, $filters);
         }
     }
     $query->setParameters($placeholders);
     return $query;
 }
 /**
  * @param string     $id
  * @param array|null $fields
  *
  * @return mixed
  */
 protected function selectOneQuery($id, array $fields = null)
 {
     $query = $this->queryBuilder();
     $q = $query->select($fields ? $fields : ['*'])->from($this->mapping->name())->andWhere($query->expr()->eq($this->mapping->identity(), ':id'))->setParameter(':id', $id);
     return $q->execute()->fetch(PDO::FETCH_ASSOC);
 }