Search Form And Wildcard

Hello everybody,

this is what I have in my controller:

$sess = Yii::app()->session;

$model = isset($sess['lastSearch'])? $sess['lastSearch'] : new SearchForm;

and this is my model:

$c = new CDbCriteria;

if(!empty($this->number)) {

   $c->compare('t.number', $code);


Everything works just fine. Now the customer asked me to introduce a wildcard, something like "123" or "12*345", so that he can search numbers like "start with" or "contains". So I did put in some logic, and still everything works fine, my logic works, but when the page reloads all the * are gone. Weird thing is that this happens only with the "number" field, all other fields will keep the * after the search. So this app is connecting to a MSSQL server, where the number field in my table is primary key and integer. I wonder if the framework or the db abstraction layer are somehow "sanitizing" my search string… how to debug this?

Thanks a lot

How do you render the search form? Maybe you got a number type set for those integer fields and the formatter casts the value.

not sure if you set rules for model attributes, like ‘numerical’, ‘integerOnly’=>true, that will remove ‘*’, which is character not a number.

Maybe you can set a virtual variable, which is used in your search form, but still compare with numerical field.