PDO buffered query problem

Hi there,

I'm having some serious problems with the PHP Data Object functions. I'm
trying to loop through a sizeable result set (~60k rows, ~1gig) using a
buffered query to avoid fetching the whole set.

No matter what I do, the script just hangs on the PDO::query() - it
seems the query is running unbuffered (why else would the change in
result set size 'fix' the issue?). Here is my code to reproduce the problem:

<?php
$Database = new PDO(
'mysql:host=localhost;port=3306;dbname=mydatabase',
'root',
'',
array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true
)
);

$rQuery = $Database->query('SELECT id FROM mytable');

// This is never reached because the result set is too large
echo 'Made it through.';

foreach($rQuery as $aRow) {
print_r($aRow);
}
?>

If I limit the query with some reasonable number, it works fine:

$rQuery = $Database->query('SELECT id FROM mytable LIMIT 10');

I have tried playing with PDO::MYSQL_ATTR_MAX_BUFFER_SIZE and using the
PDO::prepare() and PDO::execute() as well (though there are no
parameters in the above query), both to no avail.

Any help would be appreciated,

Stewart

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Joachim Krebs [ Mo, 23 Februar 2009 19:16 ] [ ID #1990520 ]
PHP » gmane.comp.php.database » PDO buffered query problem

Vorheriges Thema: Not Valid URL
Nächstes Thema: Storing Image Location in MySQL