The condition specified through CDbCriteria in the application request does not work



  • I have a reflexing request without a related model:

    $articles = Article::model()->with(array(
                    'categories'=>array(
                        'select'=>false,
                        'joinType'=>'INNER JOIN',
                        'condition'=>'categories.id = :catId',
                        'params'=>array(':catId'=>$option),
                        'distinct'=>true,
                    ),
                ))->findAll('is_reklama=:isRekl', array(':isRekl'=>1));
    

    If I give a condition in findAll() as $condition: findAll('is_reklama=:isRekl', array(':isRekl'=>1))It's doing great. If I pass through CDbCriteria:

    $criteria=new CDbCriteria;
    $criteria->condition='is_reklama=:isRekl';
    $criteria->params=array(':isRekl'=>1);
    ...
    findAll($condition);
    

    that condition doesn't work, though it must be... Show me how to do the right thing with the CDbCriteria condition.



  • $criteria = new CDbCriteria();
    $criteria->addCondition('is_reklama = :isReklama');
    $criteria->params = [
         'isReklama' => 1
    ];
    // Другие условия
    ...->findAll($criteria);
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2