Thanks for the quick response 🙂
Yes, I can see how it may feel wrong coming from an OO standpoint. However, coming from perl it just feels annoying to do it the other way hehe 🙂
For instance, I have a bunch of DB Records (Tables), and each one has Record.php, with some functions that always are called on all types of records (i.e. saving, etc).
In perl, at least in my company's system, when a new object is instantiated, the constructor automatically fetches all the info for that record from the DB and loads it into the hash.
So if we have a Person, we create the new Person object, then can do things like $person->{FirstName}, etc etc. This is really nice because for some of our clients we are constantly adding new fields to our different class types. So, when we add a new field to the actual DB record, and the object is created, that new field will automatically be available ... If we didnt do this, every time we create a new field in the DB, we would have to add a new variable declaration.
Hopefully that explanation makes sense as to why I am used to doing it this way. However, now that I think about it, it is probably equally easy to have the constructor load the values from the DB into some array for later use and just access it like $person->data['FirstName']
While I was waiting for a reply, I actually stumbled upon the set and get magic functions. Is it not required to declare these with the example you stated above, or do they just provide the ability to expand on this basic premise with more details/functions?