|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-02-09 20:07 UTC] 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;
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 22:00:01 2025 UTC |
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); ?>