#41211 [Opn->Csd]: PDO Example 1687
| From: | colder@php.net | Date: | Mon, 30 Apr 2007 21:36:18 +0000 |
| Subject: | #41211 [Opn->Csd]: PDO Example 1687 | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969376214@lists.php.net to get a copy of this message | ||
ID: 41211
Updated by: colder@php.net
Reported By: eugene dot pikalov at gmail dot com
-Status: Open
+Status: Closed
Bug Type: Documentation problem
PHP Version: Irrelevant
-Assigned To:
+Assigned To: colder
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
Previous Comments:
------------------------------------------------------------------------
[2007-04-27 10:49:55] eugene dot pikalov at gmail dot com
Description:
------------
http://www.php.net/manual/en/ref.pdo.php
Error in example
Reproduce code:
---------------
<?php
$db = new PDO('oci:', 'scott', 'tiger');
$stmt = $db->prepare("insert into images (id, contenttype, imagedata) "
.
"VALUES (?, ?, EMPTY_BLOB()) RETURNING imagedata INTO ?");
$id = get_new_id(); // some function to allocate a new ID
// assume that we are running as part of a file upload form
// You can find more information in the PHP documentation
$fp = fopen($_FILES['file']['tmp_name'], 'rb');
$stmt->bindParam(1, $id);
$stmt->bindParam(2, $_FILES['file']['type']);
$stmt->bindParam(3, $fp, PDO::PARAM_LOB);
$stmt->beginTransaction(); <--- must be $db->beginTransaction();
$stmt->execute();
$stmt->commit(); <--- must be $db->commit();
?>
Expected result:
----------------
<?php
$db = new PDO('oci:', 'scott', 'tiger');
$stmt = $db->prepare("insert into images (id, contenttype, imagedata) "
.
"VALUES (?, ?, EMPTY_BLOB()) RETURNING imagedata INTO ?");
$id = get_new_id(); // some function to allocate a new ID
// assume that we are running as part of a file upload form
// You can find more information in the PHP documentation
$fp = fopen($_FILES['file']['tmp_name'], 'rb');
$stmt->bindParam(1, $id);
$stmt->bindParam(2, $_FILES['file']['type']);
$stmt->bindParam(3, $fp, PDO::PARAM_LOB);
$db->beginTransaction();
$stmt->execute();
$db->commit();
?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41211&edit=1