php – findAll()在yii

前端之家收集整理的这篇文章主要介绍了php – findAll()在yii前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
EmailArchive表:
  1. id email_id to from
  2. 1 101 uk msm
  3. 2 102 uu avc
  4. 3 101 rk uk
  5. 4 103 xyz abc
  6. 5 104 xyz poi
  7. 6 104 abc xyz
  8. 7 101 xyz abc

现在在Yii我想要记录where email_id = 101
我使用下面的代码,但它不工作.

  1. $id =101;
  2. $criteria = new CDbCriteria();
  3. $criteria->addCondition("email_id < :email_id");
  4. $comments = EmailArchive::model()->findAll($criteria,array(':email_id' => $id,));
尝试:
  1. $id =101;
  2. $comments = EmailArchive::model()->findAll(
  3. array("condition"=>"email_id = $id","order"=>"id"));

要么

  1. $id =101;
  2. $criteria = new CDbCriteria();
  3. $criteria->addCondition("email_id=:email_id");
  4. $criteria->params = array(':email_id' => $id);
  5. $comments = EmailArchive::model()->findAll($criteria);

要么

  1. $Criteria = new CDbCriteria();
  2. $Criteria->condition = "email_id = $id";
  3. $Products = Product::model()->findAll($Criteria);

猜你在找的PHP相关文章