|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-10-04 08:42 UTC] cmb@php.net
-Package: PDO related
+Package: PDO_IBM
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 07:00:01 2025 UTC |
Description: ------------ I'm connecting DB2 using PDO IBM library, the main idea is to make a HTTP request to a download-file URI and download the file offer by endpoint. At these moments we are getting an empty result, a 0 length value, we tried with different PHP versions (7.3, 7.4, 8.0) and the results didn't change, also we tried using old versions of PDO_IBM library (1.3.5 and 1.3.6). Test script: --------------- // PDO IBM 1.4.1 $db = new PDO( 'ibm:DRIVER={IBM DB2 ODBC DRIVER};DATABASE=mydb;' . 'HOSTNAME=db2.host.url;PORT=50000;UID=user;PWD=pass', ); $sth = $db->query('SELECT id, attachment FROM my.attachment WITH UR'); $row = $sth->fetch(PDO::FETCH_ASSOC); $blob = $row['ATTACHMENT']; $stat = fstat($blob); $content = stream_get_contents($blob); if ($stat !== false && !empty($content)) { header('Content-Length: ' . $stat['size']); fpassthru($blob); } Expected result: ---------------- As a developer I want once the file is obtained from db it must be returned to HTTP body response, so that I can be able to save the file in my PC. > GET / HTTP/1.1 > Host: localhost:8080/download-file > User-Agent: curl/7.64.1 > Accept: */* > < HTTP/1.1 200 OK < Date: Fri, 01 Oct 2021 18:23:29 GMT < Server: Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1g PHP/7.4.6 < X-Powered-By: PHP/7.4.6 < Content-Length: 1024 < Content-Type: text/html; charset=UTF-8 < … < Actual result: -------------- Empty results. > GET / HTTP/1.1 > Host: localhost:8080/download-file > User-Agent: curl/7.64.1 > Accept: */* > < HTTP/1.1 200 OK < Date: Fri, 01 Oct 2021 18:23:29 GMT < Server: Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1g PHP/7.4.6 < X-Powered-By: PHP/7.4.6 < Content-Length: 0 < Content-Type: text/html; charset=UTF-8 <