CActiveDataProvider




$dataProvider=new CActiveDataProvider('Imr',array(

                'criteria' => array(

                    'select'    => "imr_id,imr_firstname,imr_lastname",          

                    'condition' => "imr_firstname LIKE '.$keyword_firstname.'")

                    'params'    => array( ':firstname' => $keyword_firstname )

                )

            );



How can run "like" sql in CActiveDataProvider ?

Here’s how to create a “LIKE” condition for CDbCriteria:




$criteria->condition = "imr_firstname LIKE '%some_string%'";






$dataProvider=new CActiveDataProvider('Imr',array(

                'criteria' => array(

                    'select'    => "imr_id,imr_firstname,imr_lastname",          

                    'condition' => "imr_firstname LIKE '%:firstname%'"),

                    'params'    => array( ':firstname' => $keyword_firstname ),

                )

            );



Above code should work.

Sorry But this code is not working properly… Its showing all the rows from the table…

Could you please check it once again??

Could happen if $keyword_firstname is empty.

Yep. thanks for the tip. Its working now.