0

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

Swissa Yaakov
  • 186
  • 3
  • 15

2 Answers2

1

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.

Nikolas Grottendieck
  • 2,548
  • 1
  • 24
  • 24
  • i am sure that i want to use "strstr" but i want to compare ":id" to google.com, so i want to read the ":id" (lets say: google.ru) after do. so it will be like .ru => .com – Swissa Yaakov Dec 09 '13 at 09:44
  • Criteria / Params doesn't work like that. Params contains an `array(key => value)` where key represents the condition placeholder in `condition`. You need to modify the condition to reflect what you actually want to compare: `'condition' => "'.com'=:id",` – Nikolas Grottendieck Dec 09 '13 at 10:36
0

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.

Nico Savini
  • 458
  • 3
  • 10