db abstraction: pass by reference versus return
| From: | Lukas Smith | Date: | Thu, 11 Jul 2002 14:16:30 +0000 |
| Subject: | db abstraction: pass by reference versus return | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-7660@lists.php.net to get a copy of this message | ||
Hi,
I think PEAR DB is also pretty consistent with always returning any data
directly versus storing data in variables that are passed by reference.
Metabase mostly does passing by reference and so MDB ATM is a bit of a
mix:
1) The question is about if methods should always either return DB_OK or
an error object and any return data should be placed into a var that is
passed by reference.
2) Alternatively the method can either return the data or an error
object. ("the PEAR DB way").
3) Finally we can have a mix. If this is the option then we need to
decide what methods should work which way ("the Metabase way").
I think this is a major useability question so I just wanted to ensure
that this is done the way people really want it to be.
Somehow 1) seems like the comp sci way of doing things as it just feels
cleaner to me. :-)
The advantage of getting DB_OK on ok is that I could actually check for
this instead of the more costly isError().
On the other hand some methods (such as type conversion and maybe also
sequences) will be a bit cumbersome to use if the var is passed by
reference, because then I cant write it directly into a query ('Select *
from foo WHERE bar = '.$mdb->getTextValue($bar))
So I am not sure if 1) is really the way to go. Leaving 2) and 3) - with
3) requiring a decision on what methods should behave in what way.
Best regards,
Lukas Smith
smith@dybnet.de
_______________________________
DybNet Internet Solutions GbR
Reuchlinstr. 10-11
Gebäude 4 1.OG Raum 6 (4.1.6)
10553 Berlin
Germany
Tel. : +49 30 83 22 50 00
Fax : +49 30 83 22 50 07
www.dybnet.de info@dybnet.de