From: eugene dot pikalov at gmail dot com Operating system: PHP version: Irrelevant PHP Bug Type: Documentation problem Bug description: PDO Example 1687
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 bug report at http://bugs.php.net/?id=41211&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41211&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41211&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41211&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=41211&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=41211&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=41211&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=41211&r=needscript Try newer version: http://bugs.php.net/fix.php?id=41211&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=41211&r=support Expected behavior: http://bugs.php.net/fix.php?id=41211&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=41211&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=41211&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=41211&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41211&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=41211&r=dst IIS Stability: http://bugs.php.net/fix.php?id=41211&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=41211&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=41211&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=41211&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=41211&r=mysqlcfg