Fetching PDO Large Data Object

This is a discussion on Fetching PDO Large Data Object within the PHP Language forums, part of the PHP Programming Forums category; I'm using the example on the following page for selecting and fetching a large data object. <http://publib....


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 5 Days Ago
FeelLikeANut@gmail.com
 
Posts: n/a
Default Fetching PDO Large Data Object

I'm using the example on the following page for selecting and fetching
a large data object. <http://publib.boulder.ibm.com/infocenter/db2luw/
v9/index.jsp?topic=/com.ibm.db2.udb.apdv.php.doc/doc/t0023504.htm>

Here's what I've tried:


$avatarFile = tempnam('', '');
$avatarSteam = fopen($avatarFile, 'wb');

$stmt = $dbh->prepare('SELECT user_avatar FROM users WHERE user_id =
29');
$stmt->execute();
$stmt->bindColumn('user_avatar', $avatarSteam, PDO::PARAM_LOB);
$stmt->fetch(PDO::FETCH_BOUND);

var_dump($coverSteam);


Ideally, $coverSteam should be a stream to a temporary file containing
the large data, but instead it's coming out as a string. And holding
the large data as a string in memory is exactly what I'm trying to
avoid. What am I doing wrong and how do I fix it? (I'm using SQLite,
in case it matters.)
Reply With Quote
  #2 (permalink)  
Old 5 Days Ago
Jerry Stuckle
 
Posts: n/a
Default Re: Fetching PDO Large Data Object

FeelLikeANut@gmail.com wrote:
> I'm using the example on the following page for selecting and fetching
> a large data object. <http://publib.boulder.ibm.com/infocenter/db2luw/
> v9/index.jsp?topic=/com.ibm.db2.udb.apdv.php.doc/doc/t0023504.htm>
>
> Here's what I've tried:
>
>
> $avatarFile = tempnam('', '');
> $avatarSteam = fopen($avatarFile, 'wb');
>
> $stmt = $dbh->prepare('SELECT user_avatar FROM users WHERE user_id =
> 29');
> $stmt->execute();
> $stmt->bindColumn('user_avatar', $avatarSteam, PDO::PARAM_LOB);
> $stmt->fetch(PDO::FETCH_BOUND);
>
> var_dump($coverSteam);
>
>
> Ideally, $coverSteam should be a stream to a temporary file containing
> the large data, but instead it's coming out as a string. And holding
> the large data as a string in memory is exactly what I'm trying to
> avoid. What am I doing wrong and how do I fix it? (I'm using SQLite,
> in case it matters.)
>


Where does $coverStream come from? The first time you use it here is on
the var_dump() call.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Reply With Quote
  #3 (permalink)  
Old 5 Days Ago
Jeff.M
 
Posts: n/a
Default Re: Fetching PDO Large Data Object

On May 7, 3:15 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> FeelLikeA...@gmail.com wrote:
> > I'm using the example on the following page for selecting and fetching
> > a large data object. <http://publib.boulder.ibm.com/infocenter/db2luw/
> > v9/index.jsp?topic=/com.ibm.db2.udb.apdv.php.doc/doc/t0023504.htm>

>
> > Here's what I've tried:

>
> > $avatarFile = tempnam('', '');
> > $avatarSteam = fopen($avatarFile, 'wb');

>
> > $stmt = $dbh->prepare('SELECT user_avatar FROM users WHERE user_id =
> > 29');
> > $stmt->execute();
> > $stmt->bindColumn('user_avatar', $avatarSteam, PDO::PARAM_LOB);
> > $stmt->fetch(PDO::FETCH_BOUND);

>
> > var_dump($coverSteam);

>
> > Ideally, $coverSteam should be a stream to a temporary file containing
> > the large data, but instead it's coming out as a string. And holding
> > the large data as a string in memory is exactly what I'm trying to
> > avoid. What am I doing wrong and how do I fix it? (I'm using SQLite,
> > in case it matters.)

>
> Where does $coverStream come from? The first time you use it here is on
> the var_dump() call.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================


Sorry. It was a mistake in the post. Shoulda been $avatarSteam.
Reply With Quote
  #4 (permalink)  
Old 5 Days Ago
FeelLikeANut@gmail.com
 
Posts: n/a
Default Re: Fetching PDO Large Data Object

On May 7, 3:15 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> FeelLikeA...@gmail.com wrote:
> > I'm using the example on the following page for selecting and fetching
> > a large data object. <http://publib.boulder.ibm.com/infocenter/db2luw/
> > v9/index.jsp?topic=/com.ibm.db2.udb.apdv.php.doc/doc/t0023504.htm>

>
> > Here's what I've tried:

>
> > $avatarFile = tempnam('', '');
> > $avatarSteam = fopen($avatarFile, 'wb');

>
> > $stmt = $dbh->prepare('SELECT user_avatar FROM users WHERE user_id =
> > 29');
> > $stmt->execute();
> > $stmt->bindColumn('user_avatar', $avatarSteam, PDO::PARAM_LOB);
> > $stmt->fetch(PDO::FETCH_BOUND);

>
> > var_dump($coverSteam);

>
> > Ideally, $coverSteam should be a stream to a temporary file containing
> > the large data, but instead it's coming out as a string. And holding
> > the large data as a string in memory is exactly what I'm trying to
> > avoid. What am I doing wrong and how do I fix it? (I'm using SQLite,
> > in case it matters.)

>
> Where does $coverStream come from? The first time you use it here is on
> the var_dump() call.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================


Sorry. That was a mistake in the post. It should be $avatarSteam.
Reply With Quote
  #5 (permalink)  
Old 4 Days Ago
Rik Wasmus
 
Posts: n/a
Default Re: Fetching PDO Large Data Object

On Wed, 07 May 2008 20:43:45 +0200, <FeelLikeANut@gmail.com> wrote:

> I'm using the example on the following page for selecting and fetching
> a large data object. <http://publib.boulder.ibm.com/infocenter/db2luw/
> v9/index.jsp?topic=/com.ibm.db2.udb.apdv.php.doc/doc/t0023504.htm>
>
> Here's what I've tried:
>
>
> $avatarFile = tempnam('', '');
> $avatarSteam = fopen($avatarFile, 'wb');
>
> $stmt = $dbh->prepare('SELECT user_avatar FROM users WHERE user_id =
> 29');
> $stmt->execute();
> $stmt->bindColumn('user_avatar', $avatarSteam, PDO::PARAM_LOB);
> $stmt->fetch(PDO::FETCH_BOUND);
>
> var_dump($coverSteam);
>
> Ideally, $coverSteam should be a stream to a temporary file containing
> the large data, but instead it's coming out as a string. And holding
> the large data as a string in memory is exactly what I'm trying to
> avoid. What am I doing wrong and how do I fix it? (I'm using SQLite,
> in case it matters.)


I'll see if I can reproduce this tomorrow, in the mean while: a big report
that isn't yet solved seems to be filed:
http://bugs.php.net/bug.php?id=40913
--
Rik Wasmus
Reply With Quote
  #6 (permalink)  
Old 4 Days Ago
Rik Wasmus
 
Posts: n/a
Default Re: Fetching PDO Large Data Object

On Thu, 08 May 2008 03:26:24 +0200, Rik Wasmus
<luiheidsgoeroe@hotmail.com> wrote:

> On Wed, 07 May 2008 20:43:45 +0200, <FeelLikeANut@gmail.com> wrote:
>
>> I'm using the example on the following page for selecting and fetching
>> a large data object. <http://publib.boulder.ibm.com/infocenter/db2luw/
>> v9/index.jsp?topic=/com.ibm.db2.udb.apdv.php.doc/doc/t0023504.htm>
>>
>> Here's what I've tried:
>>
>>
>> $avatarFile = tempnam('', '');
>> $avatarSteam = fopen($avatarFile, 'wb');
>>
>> $stmt = $dbh->prepare('SELECT user_avatar FROM users WHERE user_id =
>> 29');
>> $stmt->execute();
>> $stmt->bindColumn('user_avatar', $avatarSteam, PDO::PARAM_LOB);
>> $stmt->fetch(PDO::FETCH_BOUND);
>>
>> var_dump($coverSteam);
>>
>> Ideally, $coverSteam should be a stream to a temporary file containing
>> the large data, but instead it's coming out as a string. And holding
>> the large data as a string in memory is exactly what I'm trying to
>> avoid. What am I doing wrong and how do I fix it? (I'm using SQLite,
>> in case it matters.)

>
> I'll see if I can reproduce this tomorrow, in the mean while: a big
> report that isn't yet solved seems to be filed:
> http://bugs.php.net/bug.php?id=40913


s/big/bug/

It's late.....
--
Rik Wasmus
Reply With Quote
  #7 (permalink)  
Old 4 Days Ago
Jerry Stuckle
 
Posts: n/a
Default Re: Fetching PDO Large Data Object

Rik Wasmus wrote:
> On Thu, 08 May 2008 03:26:24 +0200, Rik Wasmus
> <luiheidsgoeroe@hotmail.com> wrote:
>
>> On Wed, 07 May 2008 20:43:45 +0200, <FeelLikeANut@gmail.com> wrote:
>>
>>> I'm using the example on the following page for selecting and fetching
>>> a large data object. <http://publib.boulder.ibm.com/infocenter/db2luw/
>>> v9/index.jsp?topic=/com.ibm.db2.udb.apdv.php.doc/doc/t0023504.htm>
>>>
>>> Here's what I've tried:
>>>
>>>
>>> $avatarFile = tempnam('', '');
>>> $avatarSteam = fopen($avatarFile, 'wb');
>>>
>>> $stmt = $dbh->prepare('SELECT user_avatar FROM users WHERE user_id =
>>> 29');
>>> $stmt->execute();
>>> $stmt->bindColumn('user_avatar', $avatarSteam, PDO::PARAM_LOB);
>>> $stmt->fetch(PDO::FETCH_BOUND);
>>>
>>> var_dump($coverSteam);
>>>
>>> Ideally, $coverSteam should be a stream to a temporary file containing
>>> the large data, but instead it's coming out as a string. And holding
>>> the large data as a string in memory is exactly what I'm trying to
>>> avoid. What am I doing wrong and how do I fix it? (I'm using SQLite,
>>> in case it matters.)

>>
>> I'll see if I can reproduce this tomorrow, in the mean while: a big
>> report that isn't yet solved seems to be filed:
>> http://bugs.php.net/bug.php?id=40913

>
> s/big/bug/
>
> It's late.....


Hmmm, over a year old and just assigned? Doesn't seem to be a very high
priority with them. Or maybe it's really tough to fix.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Reply With Quote
  #8 (permalink)  
Old 4 Days Ago
Rik Wasmus
 
Posts: n/a
Default Re: Fetching PDO Large Data Object

On Thu, 08 May 2008 14:52:56 +0200, Jerry Stuckle
<jstucklex@attglobal.net> wrote:

> Rik Wasmus wrote:
>> On Thu, 08 May 2008 03:26:24 +0200, Rik Wasmus
>> <luiheidsgoeroe@hotmail.com> wrote:
>>
>>> On Wed, 07 May 2008 20:43:45 +0200, <FeelLikeANut@gmail.com> wrote:
>>>
>>>> I'm using the example on the following page for selecting and fetching
>>>> a large data object. <http://publib.boulder.ibm.com/infocenter/db2luw/
>>>> v9/index.jsp?topic=/com.ibm.db2.udb.apdv.php.doc/doc/t0023504.htm>
>>>>
>>>> Here's what I've tried:
>>>>
>>>>
>>>> $avatarFile = tempnam('', '');
>>>> $avatarSteam = fopen($avatarFile, 'wb');
>>>>
>>>> $stmt = $dbh->prepare('SELECT user_avatar FROM users WHERE user_id =
>>>> 29');
>>>> $stmt->execute();
>>>> $stmt->bindColumn('user_avatar', $avatarSteam, PDO::PARAM_LOB);
>>>> $stmt->fetch(PDO::FETCH_BOUND);
>>>>
>>>> var_dump($coverSteam);
>>>>
>>>> Ideally, $coverSteam should be a stream to a temporary file containing
>>>> the large data, but instead it's coming out as a string. And holding
>>>> the large data as a string in memory is exactly what I'm trying to
>>>> avoid. What am I doing wrong and how do I fix it? (I'm using SQLite,
>>>> in case it matters.)
>>>
>>> I'll see if I can reproduce this tomorrow, in the mean while: a big
>>> report that isn't yet solved seems to be filed:
>>> http://bugs.php.net/bug.php?id=40913

>> s/big/bug/
>> It's late.....

>
> Hmmm, over a year old and just assigned? Doesn't seem to be a very high
> priority with them. Or maybe it's really tough to fix.


Indeed. Just verified it here, it still doesn't work in 5.2.4. A shame, I
was just going to use it in a project next week... It seems almost every
PDO driver has had this issue, however, for MySQL it's not fixed.

Perhaps the OP can abuse INTO DUMPFILE in MySQL if both webserver &
database are on the same machine.
--
Rik Wasmus
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:51 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0