Since: 2.0
Author: Carsten Brandt (mail@cebe.cc)
Inheritance: extends yii\base\Object
 public function testQueryBuilderRespectsQuery()
 {
     $queryParts = ['field' => ['title' => 'yii']];
     $queryBuilder = new QueryBuilder($this->getConnection());
     $query = new Query();
     $query->query = $queryParts;
     $build = $queryBuilder->build($query);
     $this->assertTrue(array_key_exists('queryParts', $build));
     $this->assertTrue(array_key_exists('query', $build['queryParts']));
     $this->assertFalse(array_key_exists('match_all', $build['queryParts']), 'Match all should not be set');
     $this->assertSame($queryParts, $build['queryParts']['query']);
 }
Esempio n. 2
0
 /**
  * Generates query from a [[Query]] object.
  * @param Query $query the [[Query]] object from which the query will be generated
  * @return array the generated SQL statement (the first array element) and the corresponding
  * parameters to be bound to the SQL statement (the second array element).
  */
 public function build($query)
 {
     if ($query->query instanceof Param) {
         $query->query = $query->query->toArray();
     }
     return parent::build($query);
 }