Hi there,
I have a code like this:
$criteria = new CDbCriteria;
$criteria->compare('BCODE', $model->BCODE, true);
$criteria->compare('PATIENT', mb_strtoupper($model->PATIENT, 'UTF-8'), true);
$criteria->compare('PESEL', $model->PESEL, true);
$criteria->select = 'ID, STAT, DATR, BCODE, PATIENT, PESEL, UDATE';
$criteria->condition .= " AND (TO_DATE(DATR, 'YYYY-MM-DD HH24:MI:SS') < Nvl('".$model->registrationDateStart."', sysdate))";
where $model->registrationDateStart is the only property of my model not related to any of columns in table.
This CDbCriteria is then put to CActiveDataProvider and it is sent to update CGridView.
When I drop SQL generated by AJAX request to update CGridView I see something like this:
Querying SQL: SELECT COUNT(*) FROM WWW_ZLEC t WHERE ((BCODE LIKE :ycp0) AND (PATIENT NOT LIKE :ycp1)) AND (PESEL LIKE :ycp2) AND (TO_DATE(DATR, 'YYYY-MM-DD HH24:MI:SS') < Nvl('', sysdate)). Bind with parameter :ycp0='%800%', :ycp1='%KOWALSKI%', :ycp2='%17%'
As you can see, the condition I add in last line of my CDbCriteria is returing an empty string instead what user entered to related form field. While SQL parts that comes from other form fileds (related to Model properties) are properly filled with values (by binding).
Why this happens like this? Is this because Yii uses parameters (values) binding and I’m trying to insert variable value directly to a string? Or did I made mistake somewhere else?
EDIT: And, if this is the reason, how to bind a value, if this is done in CDbCommand, not in CDbCriteria?