Well, what you could do is write one function that gets all the values that you need and fills the variables up with them, AND write a bunch of functions that get one value at a time. Then depending on the conditions or parameters/values needed or recieved and such, you can call the function best suited for the situation. If all the values are needed, call the function to get them all, if only a few are need, call only the functions that get the needed values, or some combination of this. You could argue that what if you need all of the values but one, well then just call the function that gets all the vars and just ignore that the last var is set. You could also do this by even having one function that it something like this:

I would prolly do something like this (maybe ;) depending on the situation...

where 0 is false (or don't get this var), and
1 is true (or get this var)

function get_somevars( getvar1 = 0, getvar2 = 0, getvar3 = 0) {



we don't get any by default, and the ones that we do want we pass the function 1 values like so...

get_somevers(1, 0, 1); // or get var1 and var3 but don't get var2



At 04:42 PM 11/1/2002 -0500, you wrote:

Hi   every1

This is a theorical question about the best way to use classes.

I have a class named anything, and also theres a table named ahything ..
The class attributes are the same fields of the table like this

Class anything {
        var $something1;
        var $something2;
        var $something3;

And the table 'anything' has 3 fields they are something1 , something2,
something3, my question:

I have a method in the class that retrieves the values for the 3
attributes from the table, there are many scripts that use this method
to get the data, but not all the scripts uses the 3 attributes, for
example a script calls the method just because only needs the attribute
something1. should i write one method to retrieve each attribute ? Or is
just fine that one method gets all data, and the scripts only uses what
it needs ?? Of course, the real class has more than 3 attributes it has
10 attributes

Any help would be very useful.


PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to