addWhere() public méthode

public addWhere ( $condition, $params )
Exemple #1
0
 /**
  * Adds where condition, more calls appends with AND.
  * @param  string condition possibly containing ?
  * @param  mixed
  * @param  mixed ...
  * @return self
  */
 public function where($condition, ...$params)
 {
     $this->emptyResultSet();
     if (is_array($condition) && $params === []) {
         // where(array('column1' => 1, 'column2 > ?' => 2))
         foreach ($condition as $key => $val) {
             if (is_int($key)) {
                 $this->sqlBuilder->addWhere($val);
                 // where('full condition')
             } else {
                 $this->sqlBuilder->addWhere($key, $val);
                 // where('column', 1)
             }
         }
     } else {
         $this->sqlBuilder->addWhere($condition, ...$params);
     }
     return $this;
 }
Exemple #2
0
 /**
  * Adds condition, more calls appends with AND.
  * @param  string condition possibly containing ?
  * @return void
  */
 protected function condition($condition, array $params, $tableChain = NULL)
 {
     $this->emptyResultSet();
     if (is_array($condition) && $params === []) {
         // where(array('column1' => 1, 'column2 > ?' => 2))
         foreach ($condition as $key => $val) {
             if (is_int($key)) {
                 $this->condition($val, [], $tableChain);
                 // where('full condition')
             } else {
                 $this->condition($key, [$val], $tableChain);
                 // where('column', 1)
             }
         }
     } elseif ($tableChain) {
         $this->sqlBuilder->addJoinCondition($tableChain, $condition, ...$params);
     } else {
         $this->sqlBuilder->addWhere($condition, ...$params);
     }
 }