insertGetId($data); } /** * 编辑品牌 * @access public * @author o1h.cn * @param array $condition 检索条件 * @param array $update 更新数据 * @return boolean */ public function editBrand($condition, $update) { return Db::name('brand')->where($condition)->update($update); } /** * 删除品牌 * @access public * @author o1h.cn * @param array $condition 检索条件 * @return boolean */ public function delBrand($condition) { $brand_array = $this->getBrandList($condition, 'brand_id,brand_pic'); $brandid_array = array(); foreach ($brand_array as $value) { $brandid_array[] = $value['brand_id']; @unlink(BASE_UPLOAD_PATH. DIRECTORY_SEPARATOR .ATTACH_BRAND. DIRECTORY_SEPARATOR .$value['brand_pic']); } return Db::name('brand')->where(array(array('brand_id','in', $brandid_array)))->delete(); } /** * 查询品牌数量 * @access public * @author o1h.cn * @param array $condition 检索条件 * @return array */ public function getBrandCount($condition) { return Db::name('brand')->where($condition)->count(); } /** * 品牌列表 * @access public * @author o1h.cn * @param array $condition 检索条件 * @param str $field 字段 * @param int $pagesize 分页信息 * @param str $order 排序 * @return array */ public function getBrandList($condition, $field = '*', $pagesize = 0, $order = 'brand_sort asc, brand_id desc') { if($pagesize) { $res= Db::name('brand')->where($condition)->field($field)->order($order)->paginate(['list_rows'=>$pagesize,'query' => request()->param()],false); $this->page_info=$res; return $res->items(); }else{ return Db::name('brand')->where($condition)->field($field)->order($order)->select()->toArray(); } } /** * 通过的品牌列表 * @access public * @author o1h.cn * @param array $condition 检索条件 * @param str $field 字段 * @param int $pagesize 分页信息 * @param str $order 排序 * @return array */ public function getBrandPassedList($condition, $field = '*', $pagesize = 0, $order = 'brand_sort asc, brand_id desc') { return $this->getBrandList($condition, $field, $pagesize, $order); } /** * 取单个品牌内容 * @access public * @author o1h.cn * @param array $condition 检索条件 * @param string $field 字段 * @return array */ public function getBrandInfo($condition, $field = '*') { return Db::name('brand')->field($field)->where($condition)->find(); } } ?>