问题
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