Answer the question
In order to leave comments, you need to log in
How to add a condition in Cdbcriteria in Yii?
Good afternoon, there are 3 tables:
t_service (CODE, NAME)
mc_faq (NAME, DESCRIPTION, EXIST)
l_service_22_faq (CODE, CODE_1, CODE_2) - linking
stackoverflow.com/questions/8044552/searching-in-y...
Used this recipe to find all the faqs for this service, there is such a moment:
At the deletion stage for mc_faq, I do EXIST = '2' - this is a complete deletion (0 - deletion)
I want to add a condition for $criteria
, so that only those FAQs with EXIST are pulled out in the grid! = 2
Tried like this;
$criteria = new CDbCriteria();
$criteria->with = array(
'faq_service' => array(
'condition' => 'CODE_1 = '.$model->CODE,
'group' => 'CODE_2',
'together'=>true
),
);
$criteria->condition = 'mc_faq.EXIST = 1';
'faq'=>array(self::MANY_MANY, 'Faq', 'l_service_22_faq(CODE_1, CODE_2)'),
'service_faq'=>array(self::HAS_MANY, 'LService22Faq', 'CODE_1'),
'service' => array( self::BELONGS_TO, 'Service', 'CODE_1' ),
'faq' => array( self::BELONGS_TO, 'Faq', 'CODE_2' ),
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question