array(), 'order' => array()); private $limit = ''; /** * @var SqlModel */ private $model; public function find() { } /** * @param $cond string Condition with "?" placeholder @ex 'field=?' * @param $value string|array|DbExpr Value. Array transformed to DbExpr(implode(',' Array)) All elements in the array mast be integer * @return SqlCriteria * @desc Allow multiple calls */ public function where($cond, $value) { $this->where[$cond] = $value; return $this; } /** * @param $field string Field @ex 'field' * @param $order_desc bool Descendant sort direction * @return SqlCriteria * @desc Allow multiple calls */ public function order($field, $order_desc = false) { $this->order['sort'][] = $field; if ($order_desc) { $this->order['order'][$field] = 'desc'; } return $this; } /** * @param $limit int * @param $offset int * @return SqlCriteria */ public function limit($limit, $offset = 0) { if ($offset) { $this->limit = (int) $offset . ','; } $this->limit .= (int) $limit; return $this; } /** * @param string $field * @return SqlCriteria */ public function select($field) { $this->select[] = $field; return $this; } /** * @param $field string * @return SqlCriteria */ public function distinct($field) { $this->distinct = $field; return $this; } }