Yii Case Sensitive Property

I have a problem with Yii case sensitivity. Now, I’m working on a table called test. Now my Yii application has to be installed on two servers. In server A, the test table has field Description. It works fine there. In server B, the test table has field ‘description’ in all small letters. Now in server B, because of description it gives the following exception Property “test.Description” is not defined. I have referred to some links which says the problem is due to case sensitivity.I need to install this application in many servers which can have case sensitive column names.

What is causing this exception. How can I avoid this exception without changing in the MySQL database.

This is mainly a matter of finding a good way to distinguish the servers. There is at least a dozen ways this can be done and the right one to use mostly depends on your environment. If you have control of your IP addresses (and in most cases even if you don’t) selecting the right server by IP is generally not a bad way to go. After that you can just use your DB abstraction layer to handle this. You’ll simply need to edit you model class like so:




class test extends CActiveRecord {

	public function tableName() {

		return $_SERVER['SERVER_ADDR']=='12.34.56.78'? 'Description':'description';

	}

}



This is only one way to do this and there are several more. For example, you could also move your server to a Windows OS which won’t care about case.