#35932 [Opn->Fbk]: PDO code samples
| From: | tony2001@php.net | Date: | Sun, 08 Jan 2006 16:13:37 +0000 |
| Subject: | #35932 [Opn->Fbk]: PDO code samples | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-91659@lists.php.net to get a copy of this message | ||
ID: 35932
Updated by: tony2001@php.net
Reported By: j dot gizmo at aon dot at
-Status: Open
+Status: Feedback
Bug Type: PDO related
Operating System: Windows 2000
PHP Version: 5.1.1
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5.1-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5.1-win32-latest.zip
Previous Comments:
------------------------------------------------------------------------
[2006-01-08 17:00:56] j dot gizmo at aon dot at
In fact, I just found out that according to the online
documentation, the syntax used in the docs is in fact correct.
However, the correct syntax does not work on PHP 5.1.1 on
Win2K; so it is more a PDO related issue than documentation
related.
------------------------------------------------------------------------
[2006-01-08 16:59:13] nlopess@php.net
this is not a documentation problem surely. PHP 5 deprecates the use of
'=& new' syntax, as objects are always references.
Please try with latest PHP 5 version available and if the problem
persists, reopen this bug, but not as a documentation problem.
------------------------------------------------------------------------
[2006-01-08 16:52:48] j dot gizmo at aon dot at
Description:
------------
In code samples for the PDO object, objects are created with
the assignment operator (=) instead of the reference operator
(=&).
Reproduce code:
---------------
//Syntax used in code samples
$conn = new PDO( $dsn );
//How it actually works
$conn =& new PDO( $dsn );
Expected result:
----------------
The output shown below the corresponding code samples.
Actual result:
--------------
On windows, the first version doesn't report any errors,
however any subsequent calls to methods of $conn results in
the following warning: "SQL State [000000] No Error. PDO
Constructor was not called."
If you use the =& operator (and make $conn a reference to the
newly created object) everything works as expected.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=35932&edit=1