CGridView and searching PK

Hello amazing coders,

I began to play with CGridView and there’s something that I can’t find a easy solution for it :

when I search for a number (like a Primary key) in it, it returns not the appropriate one.

Example : I got these IDs on my mysql table : 1,2,3,…,11,12,13 and I search for the number 1. The results will be 1,11,12,13.

So is there something in the code to specify that I want the exact word when I do a search ?

I know that I can specify "=" at the start of my search, but I want to find a coding way to do it.

Thank’s for your time :)

The search is performed in the model->search() function… there you can set the desired condition…

if you need more help, just post here your search() function…

If you put to your ID column’s filter box just 1 then you get, what you are writing. If you put there =1 - you’ll get only one record (row) with ID=1.

Is this what, you are looking for?


I known the ‘=’ trick, but I wanted to find a way do it in the code.

Thank you mdomba, that was the search() function that I was looking for. I just Had to set the option ‘partialMatch’ to false of the column :). Thank you !

I am starting with yii, so I was not sure how to do this, your help is appreciated.

Thank’s again mdomba and Trejder for your time!

No, problem! Anytime! If you have problem, any problem, try to search documentation and forum and if you don’t find answer, go ahead - and ask. If anyone would have time, will answer for sure. As jacmoe stated once, or twice - it is both sides pleasure, as not only the one who asks, but also the one, who answers, gets experience, knowledge and new look at old situation, from nearly each discussion. Cheers!