Example #1
0
 /**
  * Checks for an expression for a QB defintion
  *
  * When $expression is an array than it is treated like a QB defintion. A new QB instance will be created and the
  * expression will be parsed. Parameters used in the expression will be added to the parents parameterlist.
  * When the expression is no array the expression will be returned unchanged.
  *
  * @param string $expression
  *            The expression to check for an array with a QB definition
  *
  * @return string
  */
 private function checkSubquery($expression)
 {
     if (is_array($expression)) {
         $qb = new QueryBuilder($expression);
         // Build sql string and replace the existing expression with it
         $expression = '(' . $qb->build() . ')';
         // Add possible params to parents params array
         $this->params += $qb->getParams();
     }
     return $expression;
 }
Example #2
0
 /**
  * Run QueryBuilder as definition parser to create a sql query
  *
  * @param array $definition
  *            QueryBuilder definition array
  * @param bool $autoexec
  *            Optional flag to autoexecute the created query
  *
  * @return \PDOStatement
  */
 public function qb(array $definition, $autoexec = false)
 {
     $builder = new QueryBuilder($definition);
     // Build sql string
     $this->sql = $builder->build();
     // Get params
     $this->params = $builder->getParams();
     return $this->query($autoexec);
 }