/** * 通过主键,删除一条记录 * @param integer $categoryId * @return integer */ public function removeByPk($categoryId) { if (($categoryId = (int) $categoryId) <= 0) { return false; } $tableName = $this->getTblprefix() . TableNames::getCategories(); $sql = $this->getCommandBuilder()->createDelete($tableName, '`category_id` = ?'); $rowCount = $this->delete($sql, $categoryId); return $rowCount; }
/** * 获取“类别名”验证规则 * @param mixed $value * @return array */ public function getCategoryNameRule($value) { return array('MinLength' => new validator\MinLengthValidator($value, 2, Lang::_('SRV_FILTER_POST_CATEGORIES_CATEGORY_NAME_MINLENGTH')), 'MaxLength' => new validator\MaxLengthValidator($value, 20, Lang::_('SRV_FILTER_POST_CATEGORIES_CATEGORY_NAME_MAXLENGTH')), 'DbExists2' => new validator\DbExists2Validator($value, false, Lang::_('SRV_FILTER_POST_CATEGORIES_CATEGORY_NAME_UNIQUE'), $this->getDbProxy(), TableNames::getCategories(), 'category_name', 'category_pid', $this->category_pid)); }