Let's say I have a User class.
This User class has some variables, namely id, name, date_of_birth, username etc.
Should I just create one separate function to return each attribute?
Or would it be better to create just one main function and return all the User variables as array items?
I'm guessing the first one should be less taxing for the database. But requires a lot more coding.
Using multiple functions for returning or one main function
Moderator: General Moderators
Re: Using multiple functions for returning or one main function
I will say the standard is to have setters and getters for each member function.
One reason that comes tom mind is to help prevents bugs
if you do a get('firstname')
you could , by mistake, type get('firsttname') and you will not get the data
One reason that comes tom mind is to help prevents bugs
if you do a get('firstname')
you could , by mistake, type get('firsttname') and you will not get the data