Case Sensitive Model Attributes For Case Insensitive Db

I understand that Postgres is case insensitive with respect to column names. I’ve read the recommendation to use lower case attribute names, but I’d like the models to be able to use camel hump names and have Yii do the magic behind the scenes when dealing with the DB. [size=2]For example, I’d like to reference $user->userName in the model, regardless of the DB implementation. It just makes for more readable code. (I don’t want to use underscores, partly because I migrated from MySQL and have 66 tables with columns already named, along with lots of existing code.) Is there a setting somewhere that will allow me to do this?[/size]

[color="#ff0000"][size="2"]I found an answer to my own question and hoping it may help others.[/size][/color]

[color="#ff0000"][size="2"]If you use double quotes when defining tables in Postgres the case sensitivity is preserved. [/size][/color]


create table "FooBar" ("myColName" char);


[color="#ff0000"][size="2"]This causes the model generator in Yii to generate nicely humped attribute names. Unfortunately, to reference those columns in SQL queries in Yii you then need to use the double quotes. That includes when specifying the column names for conditions. For example:[/size][/color]

$condition = '"organizationId" = :orgId'