mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
update for oracle LOB support
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@199581 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
eb99af0e0c
commit
213eb7bb43
1 changed files with 38 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version='1.0' encoding='iso-8859-1'?>
|
||||
<!-- $Revision: 1.43 $ -->
|
||||
<!-- $Revision: 1.44 $ -->
|
||||
<!-- Purpose: database.abstract -->
|
||||
<!-- Membership: pecl, bundled -->
|
||||
<!-- State:experimental -->
|
||||
|
@ -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();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
<example><title>Inserting an image into a database: Oracle</title>
|
||||
<para>
|
||||
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:
|
||||
</para>
|
||||
<programlisting role='php'>
|
||||
<![CDATA[
|
||||
<?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();
|
||||
$stmt->execute();
|
||||
$stmt->commit();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
||||
</section>
|
||||
|
||||
<section id='pdo.classes'>
|
||||
|
|
Loading…
Reference in a new issue