ID:               38015
 User updated by:  sunaoka+bugs dot php dot net at gmail dot com
 Reported By:      sunaoka+bugs dot php dot net at gmail dot com
-Status:           Bogus
+Status:           Open
 Bug Type:         PDO related
 Operating System: Solaris
 PHP Version:      5.1.4
 New Comment:

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?


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

[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.

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

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

Thank you for your comment. I try using CVS snapshot, but I have
another problem.
So, I can set PDO_MYSQL_ATTR_MAX_BUFFER_SIZE, but it can not set the
value.

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

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

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

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