Re: Proper syntax for PEAR::DB?

From: Date: Wed, 19 May 2004 17:09:34 +0000
Subject: Re: Proper syntax for PEAR::DB?
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-12626@lists.php.net to get a copy of this message
Graham Clarke wrote:
Hi - In the documentation for PEAR::DB (http://pear.php.net/manual/en/package.database.db.intro-query.php) The examples all use =& instead of = // Create a valid DB object named $db $db =& DB::connect('pgsql://usr:pw@localhost/dbnam'); // Proceed with a query... $res =& $db->query('SELECT * FROM clients'); What is the preferred syntax for DB? Why?
PHP4 does not create references when using = automatically for objects. Without the & it would create copies of the objects instead of references. This can lead to issues in how PEAR works. See the php documentation on objects for details on this. regards, Lukas Smith smith@backendmedia.com _______________________________ BackendMedia www.backendmedia.com berlin@backendmedia.com Linn Zwoch Smith GbR Pariser Str. 44 D-10707 Berlin Tel +49 30 83 22 50 00 Fax +49 30 83 22 50 07

« previous php.pear.general (#12626) next »