|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-04-30 13:59 UTC] michael dot lane at fadq dot gouv dot qc dot ca
Description:
------------
I try all possibility but I'm pretty sure it's not possible to insert a file in an Oracle 12C database BLOB with PDO. All the other column have a value but my BLOB data length is always 0.
Table description:
Table: LOCI_DOCU
Column Name id Data type Null?
ID 1 NUMBER (10) N
FK_SH_ID 2 NUMBER (10) N
NOM_PHYS_DOCU 3 VARCHAR2 (150 Byte) N
TIMB_MAJ 4 DATE N
USAG_MAJ 5 VARCHAR2 (12 Byte) N
ADR_DOCU 6 VARCHAR2 (200 Byte) Y
DOCU 7 BLOB Y
TAIL_DOCU 8 NUMBER (13) Y
MIME_TYPE 9 VARCHAR2 (200 Byte) Y
Test script:
---------------
$connection = $this->getConnection();
$sql = "INSERT INTO LOCI_DOCU
(fk_sh_id, nom_phys_docu, tail_docu, mime_type, docu)
VALUES (:FK, :NAMEFILE, :SIZEFILE, :MIMEFILE, EMPTY_BLOB())
RETURNING DOCU INTO :FILELOB";
$stmt = $connection->prepare($sql);
$stmt->bindParam(":FK", 1, PDO::PARAM_INT);
$stmt->bindParam(":NAMEFILE", 'MyFileName.jpg, PDO::PARAM_STR);
$stmt->bindParam(":SIZEFILE", 278743, PDO::PARAM_INT);
$stmt->bindParam(":MIMEFILE", "image/jpeg", PDO::PARAM_STR);
$stmt->bindParam(":FILELOB", 50, PDO::PARAM_LOB);
$stmt->execute();
Expected result:
----------------
Row insert with no error.
Get a data length of 278743 and be able to get the file working if downloaded.
Actual result:
--------------
Row insert with no error.
Data length of 0 of the BLOB in the database.
When downloading file, can not show result of the original inserted file, broken file with no content.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 03:00:01 2025 UTC |
I forgot in my example the value of the PDO::PARAM_LOB. $fp = fopen($uploadfile['tmp_name'], 'rb'); $stmt->bindParam(":FILELOB", $fp, PDO::PARAM_LOB);