$id = Yii::app()->user->getState("logId");
$name = Yii::app()->user->getState("username");
$dataProvider=Disnotification::model->findAllByAttributes(array('logID' => $id,'username'!=$name));
如何查找等于$id
但不等于$name
的记录?
答案 0 :(得分:3)
$criteria = new CDbCriteria();
$criteria->compare('logID' , $id);
$criteria->addCondition('username != :username');
$criteria->params[ ':username' ] = $name;
$dataProvider = Disnotification::model()->findAll( $criteria );
答案 1 :(得分:3)
$criteria=new CDbCriteria;
$criteria->condition = "username != '$name' AND logID = :id";
$criteria->params = array (
':id' => $id,
);
$dataProvider = Disnotification::model()->findAll( $criteria );
答案 2 :(得分:0)
$dataProvider = Disnotification::model() -> findAllByAttributes(
array(
'logId'=>$id,
),
new CDbCriteria(
array(
'order'=>'x ASC, y DESC',
'condition'=>'username<>'.$username,
))
);