field($field)->where($condition)->order($order)->limit($limit)->select()->toArray(); return $result; } /** * 一条记录 * @access public * @author o1h.cn * @param array $condition 检索条件 * @param string $field 字段 * @return array 一维数组结构的返回结果 */ public function getGoodsclassstapleInfo($condition, $field = '*') { $result = Db::name('goodsclassstaple')->field($field)->where($condition)->find(); return $result; } /** * 添加常用分类,如果已存在计数器+1 * @access public * @author o1h.cn * @param type $data 参数内容 * @return boolean */ public function autoIncrementStaple($data) { $where = array( 'gc_id_1' => intval($data['gc_id_1']), 'gc_id_2' => intval($data['gc_id_2']), 'gc_id_3' => intval($data['gc_id_3']), ); $staple_info = $this->getGoodsclassstapleInfo($where); if (empty($staple_info)) { $insert = array( 'staple_name' => $data['gctag_name'], 'gc_id_1' => intval($data['gc_id_1']), 'gc_id_2' => intval($data['gc_id_2']), 'gc_id_3' => intval($data['gc_id_3']), 'type_id' => $data['type_id'], ); $this->addGoodsclassstaple($insert); } else { $update = array('staple_counter' => Db::raw('staple_counter+1')); $where = array('staple_id' => $staple_info['staple_id']); $this->editGoodsclassstaple($update, $where); } return true; } /** * 新增 * @access public * @author o1h.cn * @param array $data 参数内容 * @return boolean 布尔类型的返回结果 */ public function addGoodsclassstaple($data) { $result = Db::name('goodsclassstaple')->insertGetId($data); return $result; } /** * 更新 * @access public * @author o1h.cn * @param array $update 更新内容 * @param array $where 条件 * @return boolean */ public function editGoodsclassstaple($update, $where) { $result = Db::name('goodsclassstaple')->where($where)->update($update); return $result; } /** * 删除常用分类 * @access public * @author o1h.cn * @param array $condtion 条件 * @return boolean */ public function delGoodsclassstaple($condtion) { $result = Db::name('goodsclassstaple')->where($condtion)->delete(); return $result; } } ?>