findAll() in yii

后端 未结 8 970
日久生厌
日久生厌 2020-12-25 09:19

EmailArchive Table:

id email_id to from
1  101      uk  msm
2  102      uu  avc
3  101      rk  uk
4  103      xyz abc
5  104      xyz poi
6  104      abc xy         


        
相关标签:
8条回答
  • 2020-12-25 09:44

    Try:

    $id =101;
    $comments = EmailArchive::model()->findAll(
    array("condition"=>"email_id =  $id","order"=>"id"));
    

    OR

    $id =101;
    $criteria = new CDbCriteria();
    $criteria->addCondition("email_id=:email_id");
    $criteria->params = array(':email_id' => $id);
    $comments = EmailArchive::model()->findAll($criteria);
    

    OR

    $Criteria = new CDbCriteria();
    $Criteria->condition = "email_id = $id";
    $Products = Product::model()->findAll($Criteria);
    
    0 讨论(0)
  • 2020-12-25 09:50

    if you user $criteria, I recommend blow usage:

    $criteria = new CDbCriteria();
    $criteria->compare('email_id', 101);
    $comments = EmailArchive::model()->findAll($criteria);
    
    0 讨论(0)
提交回复
热议问题