/** * 删除分类 * * @param integer $cateId 分类ID */ public function delCate($cateId) { // 先检查该分类是否有子分类 $select = $this->db->select()->from('category', 'cate_id')->where('parent_id = ?', $cateId)->limit(1); $child = $this->db->fetchOne($select); if (!empty($child)) { throw new Regulus_Exception('该分类下有子分类,必须先删除或者转移所有子分类才能删除父分类'); } $where = $this->db->quoteInto('cate_id = ?', $cateId); $this->db->delete('category', $where); $this->_allCates = null; }
/** * @name fetchSclare * @desc 执行SQL语句并返回第一行第一列 * @param string $sql 要执行的sql语句 * @return mixed * @access public */ public function fetchSclare($sql) { $return = false; $begin_microtime = Debug::getTime(); try { $info = $this->db->fetchOne($sql, MYSQL_NUM); } catch (Exception $e) { $this->halt($e, $sql); return false; } if (!empty($info)) { $return = $info[0]; } Debug::db($this->db_host, $this->db_name, $sql, Debug::getTime() - $begin_microtime, $return); return $return; }