Hello,
I just wonder if it possible to make Yii AR feature configurable how to map AR Object Properties with Database table column names.
We has many application with with numerous tables and it’s just too hard to convert all tables to the current Yii AR conventions.
Our conventions:
Name the table with module prefix and table name:
ex: core_users <- this can be easily mapped with the model’s tableName
But we like to name our columns with prefix and underscore like
usr_id
usr_login
usr_cr_date
this way is lot easier to write complex sqls.
But in AR object is so ugly to work attribute names like $usr_cr_date we prefer $crDate
As I see in source CDbColumnSchema - name property is used for mapping and rawName for sql commands. So this would be an easy task if we can somehow tell the corresponding CDBSChema implemetation how to fetch name property from database.
Maybe we can define columnprefix in model like tableName, and pass a configuration descriptor to the CDBSchema which tells how to generate the CDbColumnSchema name property from the table descriptor (like remove prefixes, rip off underscores, uppercase words first chars etc.)
That way AR model - db mapping could be more flexible.
Regards,
Silver