|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59375 BLOB inserts broken
Submitted: 2010-08-19 08:34 UTC Modified: 2017-04-03 15:41 UTC
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: kraven at kraven dot org Assigned:
Status: Duplicate Package: PDO DBlib
PHP Version: 5.2.13 OS: Linux or Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: kraven at kraven dot org
New email:
PHP Version: OS:


 [2010-08-19 08:34 UTC] kraven at kraven dot org
BLOB inserts are broken.  A syntax error will get thrown because of improper encoding of the binary stream.

Reproduce code:
ID = INT    

    $blob_path = TESTS_BASE_DIR . '/etc/lob/propel.gif';
    $clob_path = TESTS_BASE_DIR . '/etc/lob/tin_drum.txt';
    $sql = "INSERT INTO media (COVER_IMAGE,EXCERPT,BOOK_ID) VALUES (:p1,:p2,:p3)";
    $stmt = $this->con->prepare($sql);
    $fileStream = fopen($blob_path, 'r');
    $stmt->bindParam(':p1', $fileStream, PDO::PARAM_LOB);
    $stmt->bindValue(':p2', file_get_contents($clob_path), PDO::PARAM_STR);
    $stmt->bindValue(':p3', 5, PDO::PARAM_INT);

Actual result:
PDOException: SQLSTATE[HY000]: General error: 10007 Incorrect syntax near 'GIF89a?'. [10007] (severity 5) [(null)]


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-04-01 21:20 UTC]
-Status: Open +Status: Wont fix -Package: PDO_DBLIB +Package: *General Issues
 [2017-04-01 21:20 UTC]
Due to this extension not seeing any activity since 2005, this issue will not be fixed. We are therefore closing this now.
 [2017-04-01 21:22 UTC]
-Status: Wont fix +Status: Re-Opened -Package: *General Issues +Package: PDO DBlib
 [2017-04-01 21:22 UTC]
It's no longer apart a PECL extension...
 [2017-04-03 15:41 UTC]
-Status: Re-Opened +Status: Duplicate
 [2017-04-03 15:41 UTC]
My sense is that this lines up with the known issue with quoting binary values (67495). Regular string quoting should work fine. If something's wrong there, please post a more specific bug with the data involved so I can try to reproduce.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Nov 28 09:03:14 2021 UTC