Beispiel #1
0
 /**
  * @test
  */
 public function shouldNotReplaceWhenTableNameIsPartOfOtherTableName()
 {
     //given
     $onClauses = array(WhereClause::create('products.active = true'), WhereClause::create('order_products.active = true'));
     $joinClause = new JoinClause('products', 'id', 'product_id', 'order_products', 'p', 'LEFT', $onClauses);
     //when
     $buildJoinQueryPart = DialectUtil::buildJoinQueryPart($joinClause);
     //then
     Assert::thatString($buildJoinQueryPart)->isEqualTo('LEFT JOIN products AS p ON p.id = order_products.product_id AND p.active = true AND order_products.active = true');
 }
Beispiel #2
0
 private static function _buildWhereKeyIn($column, array $array)
 {
     $useRestrictions = Arrays::any($array, Functions::isInstanceOf('\\Ouzo\\Restriction\\Restriction'));
     if ($useRestrictions) {
         return DialectUtil::joinClauses($array, 'OR', function (Restriction $restriction) use($column) {
             return $restriction->toSql($column);
         });
     }
     $in = implode(', ', array_fill(0, count($array), '?'));
     return $column . ' IN (' . $in . ')';
 }
Beispiel #3
0
 protected function _using($usingClauses, $glue = ', ', $table = null, $alias = null)
 {
     $using = DialectUtil::buildUsingQuery($usingClauses, $glue, $table, $alias);
     if ($using) {
         return ' USING ' . $using;
     }
     return '';
 }
Beispiel #4
0
 public function toSql()
 {
     return DialectUtil::joinClauses($this->conditions, 'OR', function (WhereClause $where) {
         return $where->toSql();
     });
 }