php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42768 PDO ODBC: Lob doesn't work
Submitted: 2007-09-26 13:40 UTC Modified: 2009-05-03 01:00 UTC
Votes:5
Avg. Score:4.8 ± 0.4
Reproduced:5 of 5 (100.0%)
Same Version:1 (20.0%)
Same OS:1 (20.0%)
From: sms at inbox dot ru Assigned:
Status: No Feedback Package: PDO related
PHP Version: 5.2.6 OS: Windows 2000 SP4
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sms at inbox dot ru
New email:
PHP Version: OS:

 

 [2007-09-26 13:40 UTC] sms at inbox dot ru
Description:
------------
I try to get a long binary field from Microsoft SQL Server. This simple thing is quite problematic with PDO ODBC. I already reported bug #42765. Now I found a way to bypass it and faced another big problem.

PDO returns long binary fields always as HEX string which is also corrupted. LOBs doesn't work at all... So there's simply no way to get correct binary data with PDO.

So I'm forced to use ODBC unified extension.

Reproduce code:
---------------
<plaintext>
<?php
$dbh=new PDO('odbc:Driver={SQL Server};Server=localhost;Database=test','user','pass');

$s=$dbh->prepare("set textsize 10485760; select [nbin] from [atts] where [id]=1");
$s->bindColumn('nbin',$bin,PDO::PARAM_LOB);
$s->execute();
$s->fetch(PDO::FETCH_BOUND);
var_dump($bin);
?>

Note: "set textsize" to bypass bug #42765

Expected result:
----------------
$bin should be a stream object


Actual result:
--------------
$bin is a string instead:
string(385) "24733D246462682D3E707265706172652822736574205445585453495A452031303438353736303B2073656C656374206E62696E2066726F6D2074626C417474732077686572652069644174743D363222293B0D0A24732D3E62696E64436F6C756D6E28276E62696E272C2462696E2C50444F3A3A504152414D5F4C4F4229&#65533;3B0D0A24732D3E6578656375746528293B0D0A24732D3E66657463682850444F3A3A46455443485F424F554E44293B0D0A7661725F64756D70282462696E29&#65533;&#65533;3B"

Why is it HEX-coded anyway?..

pack("H*",$bin) gives warning "illegal hex digit" and the result differs from actual field value.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-06-15 21:01 UTC] php080615 at prodpartners dot com
I have the same problem with PDO lobs returning hex coded strings under Windows 2003 Server however my same code works under linux/freetds.  Problem has persisted for over six months with various minor versions of PHP 5.2.  Currently using 5.2.6 with Windows 2003 Server
 [2009-04-25 14:50 UTC] jani@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2009-05-03 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2013-09-06 13:38 UTC] xilentd at gmail dot com
There is a null-byte after every 254 symbols of blob, pack('H*', str_replace("\0", '', $blob)) works for me on Windows with Native Client.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 13 21:01:31 2024 UTC