Yii criteria params array whit strstr function

156 views Asked by At

I have this criteria params array (i try this, but it's not working):

$dataProvider = new CActiveDataProvider('mydata', array(
        'criteria'=>array(
            'condition' => 'row=:id', 
                'params' => array(**strstr(':id', '.')** => '.com') 
        ),

i need to add a strstr function to a params how can i do that?

thanx from advance

2

There are 2 answers

0
Nico Savini On

I don't fully understand what you want to do but parameters should be used directly as values for queries.

You can parse/work with the parameter before sending it to the criteria or you could also try changing your query to work as you need it to. If you can provide me a more detailed example, maybe I can give you another opinion.

2
Nikolas Grottendieck On

You should call the strstr function at the right place first of all:

'params' => array(':id' => strstr('.com', '.')) 

Also make sure you actually want strstr as:

Returns part of haystack string starting from and including the first occurrence of needle to the end of haystack.