In Reply to:
>I have a question.
>How can i define some flexible variables?
You would have to have a method in your object that echoed passed variable
names. So it would look like this instead:
Or create an array within your object that contains your result set, then it
could look like this:
It would probably be better as a 2-dim array actually like this:
That way you would know what row to fetch from the database, and could cycle
through the results.
I think the way it should be done from an OOP design perspective is:
echo $obj->write($i, ID);
echo $obj->write($i, TOWN);
echo $obj->write($i, PHONE);
Because the value of properties should only be accessed by and objects
methods. Programming references like:
Should really be:
that returns the desired information.
Regardless I don't see how you can do what you want with an object. You
have to declare all of your variable (property) names at the begining of the
object's definition, so they really can't be variable. Use an array, or a
I suppose you might be able to have the constructor handle variable names
that you pass, but it still would not look like your example, and would
require that you create a new object everytime.
I probably just made things more confusing. If you really need help, repost
with more info and I'm sure you will find help.
From: Mircea Romanitan [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 20, 2001 11:42 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] flexible variables
I have a question.
How can i define some flexible variables?
Suppose i have a table with (id, town, phone).
In a file i have
define ("ID", "id");
define ("TOWN", "town");
define ("PHONE", "phone");
and after i send a query( SELECT * FROM table) to that db and got the query
into an object,
i need to write:
but i cannot figure how?
I tried to use variable variables, but it don't work.
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]