示例#1
0
文件: SelectQuery.php 项目: bolt/bolt
 /**
  * Internal method that runs the individual key/value input through
  * the QueryParameterParser. This allows complicated expressions to
  * be turned into simple sql expressions
  */
 protected function processFilters()
 {
     $this->filters = [];
     foreach ($this->params as $key => $value) {
         $this->parser->setAlias($this->contentType);
         $filter = $this->parser->getFilter($key, $value);
         if ($filter) {
             $this->addFilter($filter);
         }
     }
 }
示例#2
0
 public function testAddingCustomMatcher()
 {
     $app = $this->getApp();
     $expr = $app['storage']->createExpressionBuilder();
     // In this test we'll make a custom matcher that allows a new syntax: username: '******' as an alias for a like query
     $p = new QueryParameterParser($expr);
     $p->addValueMatcher('\\~(\\w+)', ['value' => '%$1%', 'operator' => 'like'], true);
     $filter = $p->getFilter('username', '~test');
     $this->assertEquals('username LIKE :username_1', $filter->getExpression());
     $this->assertEquals(['%test%'], array_values($filter->getParameters()));
 }