From 213eb7bb4389faee935d56d78ff36a08dadd99e8 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Mon, 31 Oct 2005 03:06:55 +0000 Subject: [PATCH] update for oracle LOB support git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@199581 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/pdo/reference.xml | 39 ++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/reference/pdo/reference.xml b/reference/pdo/reference.xml index 74e5de8832..d3e341a816 100644 --- a/reference/pdo/reference.xml +++ b/reference/pdo/reference.xml @@ -1,5 +1,5 @@ - + @@ -751,12 +751,49 @@ $stmt->bindParam(1, $id); $stmt->bindParam(2, $_FILES['file']['type']); $stmt->bindParam(3, $fp, PDO::PARAM_LOB); +$stmt->beginTransaction(); $stmt->execute(); +$stmt->commit(); +?> +]]> + + + + + Inserting an image into a database: Oracle + + Oracle requires a slightly different syntax for inserting a lob from a + file. It's also essential that you perform the insert under a + transaction, otherwise your newly inserted LOB will be committed with a + zero-length as part of the implicit commit that happens when the query + is executed: + + +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(); +$stmt->execute(); +$stmt->commit(); ?> ]]> +