@link https://docs.bolt.cm/templates/content-fetching The resulting QueryBuilder object is then passed through to the individual field handlers where they can perform value transformations.
Author: Ross Riley (riley.ross@gmail.com)
Inheritance: implements Bolt\Storage\Query\QueryInterface
Exemple #1
0
 public function testQuery()
 {
     $app = $this->getApp();
     $filters = ['username' => '%fred%', 'email' => '%fred', 'status' => 'published'];
     $query = new SelectQuery($app['storage']->createQueryBuilder(), $app['query.parser.handler']);
     $query->setContentType('pages');
     $query->setParameters($filters);
     $expr = $query->getWhereExpression();
     $this->assertEquals('(pages.username LIKE :username_1) AND (pages.email LIKE :email_1) AND (pages.status = :status_1)', $expr->__toString());
     $this->assertEquals(['%fred%', '%fred', 'published'], array_values($query->getWhereParameters()));
 }
Exemple #2
0
 /**
  * This overrides the SelectQuery default to do some extra preparation for a search query.
  * Firstly it builds separate filters for the search query and then it removes the filter
  * from the params and the others will then get processed normally by the parent.
  */
 protected function processFilters()
 {
     if (!$this->contentType) {
         throw new QueryParseException('You have attempted to run a search query without specifying a ContentType', 1);
     }
     if (!($config = $this->config->getConfig($this->contentType))) {
         throw new QueryParseException('You have attempted to run a search query on an unknown ContentType or one that is not searchable', 1);
     }
     $params = $this->params;
     unset($params['filter']);
     foreach ($config as $field => $options) {
         $params[$field] = $this->getSearchParameter();
     }
     $this->params = $params;
     parent::processFilters();
 }