Skip to content

Commit c9428d4

Browse files
committed
fix for out of memory bug
1 parent 1a7a9c1 commit c9428d4

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

MysqliDb.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,9 @@ protected function _dynamicBindResults(mysqli_stmt $stmt)
769769
{
770770
$parameters = array();
771771
$results = array();
772+
// See http://php.net/manual/en/mysqli-result.fetch-fields.php
773+
$mysqlLongType = 252;
774+
$shouldStoreResult = false;
772775

773776
$meta = $stmt->result_metadata();
774777

@@ -780,13 +783,17 @@ protected function _dynamicBindResults(mysqli_stmt $stmt)
780783

781784
$row = array();
782785
while ($field = $meta->fetch_field()) {
786+
if ($field->type == $mysqlLongType)
787+
$shouldStoreResult = true;
788+
783789
$row[$field->name] = null;
784790
$parameters[] = & $row[$field->name];
785791
}
786792

787-
// avoid out of memory bug in php 5.2 and 5.3
793+
// avoid out of memory bug in php 5.2 and 5.3. Mysqli allocates lot of memory for long*
794+
// and blob* types. So to avoid out of memory issues store_result is used
788795
// https://github.com/joshcam/PHP-MySQLi-Database-Class/pull/119
789-
if (version_compare (phpversion(), '5.4', '<'))
796+
if ($shouldStoreResult)
790797
$stmt->store_result();
791798

792799
call_user_func_array(array($stmt, 'bind_result'), $parameters);

0 commit comments

Comments
 (0)