public function getLevel1Count($id) { return part::find()->select("count(id) as count")->where('pid=:pid', [':pid' => $id])->asArray()->one(); }
/** * 根据条件查询部位 * @param array $param * @return type */ public function getSearch($param) { $array = array_intersect_key($param, $this->attributes); $where = ''; $bound = []; foreach ($array as $k => $v) { if (!empty($v)) { $where .= ' and ' . $k . ' = :' . $k; $bound[':' . $k] = $v; } } $where = substr($where, 5); return part::find()->select("id,name,description,child,level")->where($where, $bound)->asArray()->all(); }