Example #1
0
 /**
  * WHERE ....
  * int ค้นหาจาก primaryKey เช่น id=1 หมายถึง WHERE `id`=1
  * string เช่น QUERY ต่างๆ `email`='xxx.com' หมายถึง WHERE `email`='xxx.com'
  * array เช่น ('id', 1) หมายถึง WHERE `id`=1
  * array เช่น ('email', '!=', 'xxx.com') หมายถึง WHERE `email`!='xxx.com'
  * ถ้าเป็น array สามารถรุบได้หลายค่าโดยแต่ละค่าจะเชื่อมด้วย $oprator
  *
  * @param mixed $where
  * @param string $oprator (options) AND (default), OR
  * @return \static
  */
 public function where($where = array(), $oprator = 'AND')
 {
     if (is_int($where) || is_string($where) && $where != '' || is_array($where) && !empty($where)) {
         $where = $this->buildWhere($where, $oprator, $this->field->table_alias . '.' . $this->field->getPrimarykey());
         if (is_array($where)) {
             $this->values = ArrayTool::replace($this->values, $where[1]);
             $where = $where[0];
         }
         $this->sqls['where'] = $where;
     }
     return $this;
 }