Example #1
0
 /**
  * Compiles the ON clause of a JOIN.
  *
  * @param  mixed  $expr
  */
 private function compileOn($expr)
 {
     if (!$expr) {
         return;
     }
     if (!$expr instanceof Composite) {
         $ret = new Composite();
         foreach ($expr as $owner => $related) {
             $ret->all([sprintf('%s = %s', $owner, $related)]);
         }
         $expr = $ret;
     }
     return [$expr->getExpr(), $expr->getBinds()];
 }
Example #2
0
 public function test_joins_withExpression()
 {
     $expr = new Composite();
     $expr->all(['b.author_id' => 1]);
     $this->subject->join('books b', $expr);
     $this->assertQuery('SELECT author.* FROM authors AS author ' . 'INNER JOIN books b ON (b.author_id = ?)', [1]);
     $this->subject->all();
 }