note 60477 rejected from function.pdo-construct by nlopess
| From: | nlopess@php.net | Date: | Sun, 08 Jan 2006 13:52:12 +0000 |
| Subject: | note 60477 rejected from function.pdo-construct by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-101405@lists.php.net to get a copy of this message | ||
Note Submitter: j dot gizmo at aon dot at
----
On Windows the sample code doesn't necessarily work. If you use
<?php
$db = new PDO("sqlite::memory:");
?>
you can get a 'No Error: Constructor not called' warning whenever you try any methods of
the $db object.
This is due to the fact that the PDO Object shouldn't be cloned (but still is cloneable). Using
the following syntax resolves the problem:
<?php
$db =& new PDO("sqlite::memory:");
?>
(Essentially, this assigns a reference of the newly created object to $db, not a copy; this way, the
$db object isn't cloned)