Andrew Sinning Fri Jul 15 10:01:17 -0400 2011

Subject: how does php.activerecord treat camelCase and under_scores?

Could somebody please clarify the rules for how php.activerecord deals with camelCase and under_scores.

It's a bit inconvenient that for example the db field "firstName" becomes the object property "firstname". Similarly, the class "UserRecord" looks by default for a table called "user_records", not userRecords.

I'm sure there is a very good reason for this. I think it would be very helpful to have it explained somewhere.


Nanne Huiges Mon Jul 18 05:38:36 -0400 2011

I don't know what the 'rules' and reasons are, but I use the following.

Tablenames go only to SQL. These are case-sensitive. Use the name it has (so you can always use "UserRecord"). Fire people who try to make tables with names that are the same except for case.

Fieldnames go to SQL and become properties. SQL is NOT case-sensitive for these, but the properties ARE. As these are used for both puproses, ALWAYS use them lowercase in your code. This way phpactiverecord doesn't get its panties all tangled :)