CDbCriteria condition from another CDbCriteria

你离开我真会死。 提交于 2020-01-25 06:44:10

问题


I don't if that I want to do is possible or not, I have two models i want to get data from one model using a condition from another.

                    $criteria1=new CDbCriteria;
        $paramIds = $s['param_id'];
        $stress = model1::model()->find($criteria1);
        $mycondition= ($stress->stress_value);

        echo $mycondition ; // I get this value and I want to use it as  
                                        // condition for the next cdbcreteria

        $criteria2=new CDbCriteria;

                     // condition
        $criteria2->addcondition(array('pressure_value' >  $mycondition));

                      // I can't  perform this condition       

        $criteria2->order = "pressure_value desc";
        $pressure = model2::model()->find($criteria2);

Any idea ? my code is wrong or what I want to do is not possible in this way ?

Many thanks


回答1:


thanks @Örs

your solution work for me with making the compare statement in cdbcreteria after the condition

$criteria2->params = array(':value' => $mycondition)


来源:https://stackoverflow.com/questions/14763774/cdbcriteria-condition-from-another-cdbcriteria

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!