How to support Oracle DB more easily?

I’m trying to make my project to support Oracle DB, but I found that it is not as simple as I think.

As in Oracle, if we quote the column or table name , it means in case sensitive mode when execute SQL. In my project, table name an column name are all lowercase, and in AR classes, they are also lowercase. It’s going well with MySQL…

I fond AR class will quote the table and column in select, like below codes in CDbCommandBuilder:


		

foreach($table->getColumnNames() as $name)

    $select[]=$prefix.$this->_schema->quoteColumnName($name);



But in condition expression, I have to do it myself, Yii can not automaticly quote the column and no simple method to do it. So I have to change my code like this




...

$criteria->condition = Yii::app()->db->quoteColumnName('type') .' = :type and ' . Yii::app()->db->quoteColumnName('name') . '=:name';

...



It seems so complicated, and what I can do is just define a short named function like q(). Unfortunately, there are nearly one hundred AR classes in my project , anyone who give me guidance ? Thanks.

Unfortunately, it looks like this isn’t going to be addressed with Yii 1, seeing as how this has been an issue for a few years now:

https://code.google.com/p/yii/issues/detail?id=2192

Creating a shorter quote function is probably your best bet at the moment. Maybe extend CActiveRecord for your models and add the method there

I found the issue is solved in Yii2. As Qiang said, CDbCriteria is the bane. But the migration from Yii to Yii2 is also complicated.