Yii Framework Forum: Yii Case Sensitive Property - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yii Case Sensitive Property Rate Topic: -----

#1 User is offline   Rudra 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 118
  • Joined: 12-July 13

Posted 22 August 2013 - 12:34 AM

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.
0

#2 User is offline   krowe 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 26
  • Joined: 27-September 12
  • Location:Peoria IL, USA

Posted 23 August 2013 - 02:40 PM

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.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users