来自另一个 CDbCriteria 的 CDbCriteria 条件 [英] CDbCriteria condition from another CDbCriteria

查看:32
本文介绍了来自另一个 CDbCriteria 的 CDbCriteria 条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道我想做的事情是否可行,我有两个模型,我想使用另一个模型的条件从一个模型中获取数据.

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 ?

非常感谢

推荐答案

感谢 @Örs

你的解决方案对我有用,在条件之后在 cdbcreteria 中做比较语句

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

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

这篇关于来自另一个 CDbCriteria 的 CDbCriteria 条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆