Bug #40913 [Com]: PDO_MYSQL: PDO::PARAM_LOB does not bind to a stream for fetching a BLOB

From: Date: Fri, 24 Jan 2014 09:52:12 +0000
Subject: Bug #40913 [Com]: PDO_MYSQL: PDO::PARAM_LOB does not bind to a stream for fetching a BLOB
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-183987@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=40913&edit=1

 ID:                 40913
 Comment by:         heruan at aldu dot net
 Reported by:        dennis at inmarket dot lviv dot ua
 Summary:            PDO_MYSQL: PDO::PARAM_LOB does not bind to a stream
                     for fetching a BLOB
 Status:             Re-Opened
 Type:               Bug
 Package:            PDO MySQL
 Operating System:   Win XP
 PHP Version:        5.2.6
 Block user comment: N
 Private report:     N

 New Comment:

Still present in PHP 5.4.9


Previous Comments:
------------------------------------------------------------------------
[2013-05-31 05:25:33] ssufficool@php.net

PGSQL binds to a stream object for a LOB. Which PDO driver is this referring to?

------------------------------------------------------------------------
[2012-11-07 12:15:02] johannes@php.net

The implementation for this is broken in PDO core. For PGSQL there is a workaround documented:

    Since information about the columns is not always
    available to PDO until the statement is executed,
    portable applications should call this function after 
    PDOStatement::execute().

    However, to be able to bind a LOB column as a stream
    when using the PgSQL driver, applications should call
    this method before calling PDOStatement::execute(),
    otherwise the large object OID will be returned as an integer.
    http://www.php.net/manual/en/pdostatement.bindcolumn.php

This works neither works with sqlite nor mysql drivers. After research I assume it won't work
with other drivers either. The LOB-handling happens in the param_hook for PDO_PARAM_EVT_EXEC_PRE.
But this event only happens if there are bound parameters during execute.
But result columns are bound after execute ...

The support for this feature has do be redesigned in PDO core ... as MySQL has no native stream
support I don't support adding a hack for this.

------------------------------------------------------------------------
[2012-11-07 08:55:18] vicrry at yahoo dot com dot hk

As of PHP 5.3.15, this bug still exists.

------------------------------------------------------------------------
[2012-08-04 12:40:50] david dot palella at gmail dot com

The problem is still present with PHP v. 5.3.10 and Ubuntu 12.10

------------------------------------------------------------------------
[2011-10-20 09:48:17] oridan82 at gmail dot com

PHP 5.3.5
PARAM_LOB is returning a string instead of a stream.

Code:
-----
$stmt = $conn->prepare($qry);
$stmt->bindValue(1, $_GET['id']);
$stmt->bindValue(2, $_GET['aid']);
$stmt->execute();

$stmt->bindColumn(4, $mimeType, PDO::PARAM_STR, 256);
$stmt->bindColumn(6, $lob, PDO::PARAM_LOB);
$stmt->fetch(PDO::FETCH_BOUND);

echo gettype($lob);


Expected Result:
----------------
resource


Actual Result:
--------------
string

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=40913


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=40913&edit=1


Thread (39 messages)

« previous php.bugs (#183987) next »