ID:               38015
 Comment by:       m dot leuffen at gmx dot de
 Reported By:      sunaoka+bugs dot php dot net at gmail dot com
 Status:           Open
 Bug Type:         PDO related
 Operating System: Solaris
 PHP Version:      5.1.4
 New Comment:

Hi there,

it seems that the buffer size can be set only during instanciation of
the PDO.

Try this:

$pdo = new PDO ("connection_settings", "user", "pass", array
(PDO::MYSQL_ATTR_MAX_BUFFER_SIZE=>1024*1024*50));

This should fix the problem.

(If not this may be a MySQL configuration issue. Check the
max_allowed_packet_size setting in your mysql configuration - and make
sure that my.cnf is on the right location)

Bye,
  Matthias


Previous Comments:
------------------------------------------------------------------------

[2006-07-13 06:14:40] sunaoka+bugs dot php dot net at gmail dot com

Thank you for your comment.

I understood why the result wasn't 'int(10485760)'. 
Then, why is there PDO_MYSQL_ATTR_MAX_BUFFER_SIZE?

After all, I cannot acquire data more than 1M byte. 
The error occurs though I tried according to the manual as follows. 

http://www.php.net/manual/en/ref.pdo.php#pdo.lobs

Reproduce code:
---------------
$db = $db = new PDO('mysql:host=localhost;dbname=test', 'user',
'pass');
$stmt = $db->prepare('SELECT FileData FROM FileInfo WHERE Id = ?');
$stmt->execute(array(1));
$stmt->bindColumn(1, $lob, PDO::PARAM_LOB);
$stmt->fetch(PDO::FETCH_BOUND);

header('Content-Type: image/jpeg');
fpassthru($lob);

Expected result:
----------------
Warning:  fpassthru(): supplied argument is not a valid stream
resourcein ...

How can I load 1M data or more?

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

[2006-07-07 12:08:55] sunaoka+bugs dot php dot net at gmail dot com

Thank you for your comment.

I understood why the result wasn't 'int(10485760)'. 
Then, why is there PDO_MYSQL_ATTR_MAX_BUFFER_SIZE?

After all, I cannot acquire data more than 1M byte. 
The error occurs though I tried according to the manual as follows. 

http://www.php.net/manual/en/ref.pdo.php#pdo.lobs

fpassthru($lob);

Warning:  fpassthru(): supplied argument is not a valid stream resource
in ...

How can I load 1M data or more?

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

[2006-07-07 08:33:05] [EMAIL PROTECTED]

>But, I do not understand why the result doesn't become
`int(10485760)'.
Why should it become equal to the size of the buffer?
Buffer is used to read the data by pieces and you can change size of of
these pieces.
This is why it's called "PDO_MYSQL_ATTR_MAX_BUFFER_SIZE" and not
"PDO_MYSQL_ATTR_MAX_DATA_SIZE".

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

[2006-07-07 06:17:08] sunaoka+bugs dot php dot net at gmail dot com

Thank you for your comment. But, I do not understand why the result
doesn't become `int(10485760)'.
I load `FileData' only 1MB.

I am using php5.2-200607060030.

Reproduce code:
---------------
try {
    $db = new PDO('mysql:host=localhost;dbname=test', 'user', 'pass');
    $db->setAttribute(PDO::MYSQL_ATTR_MAX_BUFFER_SIZE, 1024 * 1024 *
10);

    $sql = 'SELECT LENGTH(FileData) FROM FileInfo WHERE Id = ?';
    $stmt = $db->prepare($sql);
    $stmt->execute(array(1));
    $result = $stmt->fetch();
    $stmt->closeCursor();

    echo 'LENGTH(FileData):     ', $result[0], "\n";

    $sql = 'SELECT FileData FROM FileInfo WHERE Id = ?';
    $stmt = $db->prepare($sql);
    $stmt->execute(array(1));

    $stmt->bindColumn('FileData', $lob, PDO::PARAM_LOB);
    $result = $stmt->fetch(PDO::FETCH_BOUND);

    file_put_contents('/tmp/foo', $lob);
    echo "filesize('/tmp/foo'): ", filesize('/tmp/foo'), "\n";

} catch (PDOException $exception) {
    echo $exception->getMessage(), "\n";
}

Expected result:
----------------
LENGTH(FileData):     6971569
filesize('/tmp/foo'): 1048576

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

[2006-07-06 20:12:51] [EMAIL PROTECTED]

Expected result:
----------------
int(1048576)
bool(true)
int(1048576)


Right, this is the expected and ACTUAL result.
I don't see any problems there.

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

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
    http://bugs.php.net/38015

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

Reply via email to