ID:               36345
 User updated by:  milanm at datax dot biz
 Reported By:      milanm at datax dot biz
 Status:           Open
 Bug Type:         PDO related
 Operating System: Linux
 PHP Version:      5.1.2
 New Comment:

I found something strange in ext/pdo_mysql/mysql_statement.c
There is constant defined called PDO_MYSQL_MAX_BUFFER like this:
#define PDO_MYSQL_MAX_BUFFER 1024*1024
I've changed this to:
#define PDO_MYSQL_MAX_BUFFER 1024*1024*10
and recompiled PHP.
Now PDO loads whole 1.5MB from DB.
Hope that helps.


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

[2006-02-09 22:48:44] milanm at datax dot biz

When I run code bellow everithing is OK and data are 1.5 MB big. I've
also tried to downgrade mysql to 4.1 and recompile php but with no
results. Same problem persits with PDO using client library 4.1.14.
<?php

  $c  = mysql_connect('10.0.0.102', 'user', 'pass');
  mysql_select_db('test', $c);

  $res = mysql_query('SELECT data FROM test WHERE id=1', $c);

  $data = mysql_fetch_object($res);

  var_dump($data);

?>

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

[2006-02-09 20:07:54] milanm at datax dot biz

Description:
------------
I got a table and a stored 1.5 MB image in it. But when i try to load
it into variable using PDO it has only 1MB. I'm using pdo_mysql client
library 5.0.18.

Reproduce code:
---------------
<?php

  error_reporting(E_ALL);

  $dsn        = 'mysql:host=10.0.0.102;port=3306;dbname=test;';
  $user       = 'user';
  $password   = 'pass';

  $mysql_pdo  = new PDO($dsn, $user, $password);
  $blob_id    = 1;

  $stmt = $mysql_pdo->prepare('SELECT data FROM test WHERE id=:id');
  $stmt->bindParam(':id', $blob_id, PDO::PARAM_INT);

  $mysql_pdo->beginTransaction();
  $stmt->execute();
  $mysql_pdo->commit();

  $stmt->bindColumn(1, $blob_fp, PDO::PARAM_LOB);

  $stmt->fetchAll(PDO::FETCH_BOUND);

  header('Content-Type: image/jpeg');
  print $blob_fp;

?>
Table looks like this:

CREATE TABLE test (
  id      INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  name    VARCHAR(10) NOT NULL,
  data    LONGBLOB NOT NULL,
  PRIMARY KEY id (id),
  UNIQUE KEY name (name)
) type=InnoDB;




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


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

Reply via email to