Hi every one. This is the first time I use yii with postgresql, and I got this error when I try to search in cgridview search column :
Error 500: <h1>CDbException</h1>
<p>CDbCommand failed to execute the SQL statement: SQLSTATE[42883]: Undefined function: 7 ERROR: operator does not exist: timestamp without time zone ~~ unknown
LINE 1: ...FROM "tbl_product_request" "t" WHERE expired_date LIKE '%test%'
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.. The SQL statement executed was: SELECT COUNT(*) FROM "tbl_product_request" "t" WHERE expired_date LIKE :ycp0. Bound with :ycp0='%d%' (D:\xampp\htdocs\yii-1.1.12\framework\db\CDbCommand.php:528)</p><pre>#0 D:\xampp\htdocs\yii-1.1.12\framework\db\CDbCommand.php(425)
The column’s data type is datetime, and it seems like the problem is the generated query tries to compare datetime data type column with string. Anybody has the solution ? Please help. Thanks
Like you say the problem is trying to compare a date time with a string, but if you don’t wanna errors at moment of the search you may put the same format of the database column at the search field or use a calendar to do it.
Hi, so sorry for the late reply, been sick and bed rest since two days ago and just getting well today.
I used to use mysql and the compare method works well, even though the datatype is datetime. But I think I cant do that with postgre and the solution would be using addCriteria on my search function. Thanks for the solution, helps me a lot