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