Bug #69552 [Opn]: PDO INSERT BLOB in oracle 12c database
| From: | michael dot lane at fadq dot gouv dot qc dot ca | Date: | Thu, 30 Apr 2015 14:36:52 +0000 |
| Subject: | Bug #69552 [Opn]: PDO INSERT BLOB in oracle 12c database | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-192429@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=69552&edit=1
ID: 69552
User updated by: michael dot lane at fadq dot gouv dot qc dot ca
Reported by: michael dot lane at fadq dot gouv dot qc dot ca
Summary: PDO INSERT BLOB in oracle 12c database
Status: Open
Type: Bug
Package: PDO OCI
Operating System: Debian 3.2.65-
PHP Version: 5.4.40
Block user comment: N
Private report: N
New Comment:
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);
Previous Comments:
------------------------------------------------------------------------
[2015-04-30 13:59:46] 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.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69552&edit=1