Issue 2291: Mysqli prepared statements - LONGTEXT columns always come back empty

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.3.2@11083 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ucorina 2012-08-24 15:59:19 +00:00
parent 4859bc8bd9
commit c326a5bfbb

View file

@ -218,6 +218,12 @@
$meta = mysqli_stmt_result_metadata($stmt); $meta = mysqli_stmt_result_metadata($stmt);
$fields = mysqli_fetch_fields($meta); $fields = mysqli_fetch_fields($meta);
/**
* Mysqli has a bug that causes LONGTEXT columns not to get loaded
* Unless store_result is called before
* MYSQLI_TYPE for longtext is 252
*/
$longtext_exists = false;
foreach($fields as $field) foreach($fields as $field)
{ {
if(isset($resultArray[$field->name])) // When joined tables are used and the same column name appears twice, we should add it separately, otherwise bind_result fails if(isset($resultArray[$field->name])) // When joined tables are used and the same column name appears twice, we should add it separately, otherwise bind_result fails
@ -226,9 +232,16 @@
// Array passed needs to contain references, not values // Array passed needs to contain references, not values
$row[$field->name] = ""; $row[$field->name] = "";
$resultArray[$field->name] = &$row[$field->name]; $resultArray[$field->name] = &$row[$field->name];
if($field->type == 252) $longtext_exists = true;
} }
$resultArray = array_merge(array($stmt), $resultArray); $resultArray = array_merge(array($stmt), $resultArray);
if($longtext_exists)
{
mysqli_stmt_store_result($stmt);
}
call_user_func_array('mysqli_stmt_bind_result', $resultArray); call_user_func_array('mysqli_stmt_bind_result', $resultArray);
$rows = array(); $rows = array();