mySql expression in Yii active record query

Hello all,

I’m trying to do that:




  $comptes= ProfilUser::model()->with(array(

         'owner',

         'infosAdmin'=>array(

     

                       'select'=>false,

	                        

                        'condition'=>"infosAdmin.isEmailSent = 0 and infosAdmin.date_renouvellement <= :date",

                        'params' =>array(':date'=>"DATE_ADD(NOW(),INTERVAL 31 DAY)"),

	                        ),

            ))->findAllByAttributes(array('is_active'=>ProfilUser::ACTIF)); 



But the mySql generated query keep the quote ‘’ or “” around DATE_ADD(NOW(),INTERVAL 31 DAY) and then query is useless (syntax correct but useless date_renouvellement < ‘DATE_ADD(NOW(),INTERVAL 31 DAY)’ )

Do you know the meaning to generated sql query in the right way ?

Thanks

params are ment to pass constant values. if you use expression (that does not even depend on any user input) just pass it as part of condition:




$comptes= ProfilUser::model()->with(array(

         'owner',

         'infosAdmin'=>array(

     

                       'select'=>false,

                                

                        'condition'=>"infosAdmin.isEmailSent = 0 and infosAdmin.date_renouvellement <= DATE_ADD(NOW(),INTERVAL 31 DAY)",

                                ),

            ))->findAllByAttributes(array('is_active'=>ProfilUser::ACTIF)); 



if you want to apply some logic on passed date - use the param but only for the constant value:




  'condition'=>"infosAdmin.isEmailSent = 0 and infosAdmin.date_renouvellement <= DATE_ADD(:date,INTERVAL 31 DAY)",

  'params' =>array(':date'=>"2012-01-10"),



Many thank @redGuy

works like a charm