/** * 判断符合条件的记录是否存在 * <pre> * $_where = "name=:name AND sex=:sex AND date >= :date"; * $_aryParams = array( * ':name'=>'xx', * ':sex'=>'man', * ':date'=>'2010-06-15', * ); * </pre> * @param string $_where * @param array $_aryParams * @return bool */ public function exists($_where = "", $_aryParams = array()) { $criteria = new CDbCriteria(); $criteria->from = $this->tableName(); $criteria->condition = $_where; $criteria->offset = 0; $criteria->limit = 1; $aryRes = $this->getDb()->find($criteria->toSql(), $_aryParams); return empty($aryRes) ? false : true; }