I'm fairly new to OOP, but I really like the way PHP implements them, so I'm getting more into it here.
I have a question about space and time on object methods. Let's say I set up 10 properties for a system user (username, password, uid) etc.
Now lets say I decide to code, into the object itself, the SQL statement to commit that record to the database, and another SQL statement to pull a user record from the database, and populate the objects properties... both of them methods (ie $user->commit(), $user->getInfo(), etc etc)
My question is... let's say I create 20 user objects in a script... am I also creating 20 blocks of code for those methods in memory? Or does php do something like reference the object code.
See, I know I have 20 separate copies of $user->username and $user->password, but am I also creating the code as well?
I'm pondering this because I'd like to keep the DB insert/retrieve functions inside that object for cleanliness, but yet if I'm actually making 20 copies of the method code in RAM, then I'd rather just make a small external function library for the commits.
This is something I don't know about, and I hope someone here can help me with.