From c326a5bfbb1e8b6cffd5dfd96b7f72d6950c525a Mon Sep 17 00:00:00 2001 From: ucorina Date: Fri, 24 Aug 2012 15:59:19 +0000 Subject: [PATCH] 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 --- classes/db/DBMysqli.class.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/classes/db/DBMysqli.class.php b/classes/db/DBMysqli.class.php index 64e9aa850..cb675f27b 100644 --- a/classes/db/DBMysqli.class.php +++ b/classes/db/DBMysqli.class.php @@ -217,8 +217,14 @@ $stmt = $result; $meta = mysqli_stmt_result_metadata($stmt); $fields = mysqli_fetch_fields($meta); - - foreach($fields as $field) + + /** + * 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) { 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 $field->name = 'repeat_' . $field->name; @@ -226,9 +232,16 @@ // Array passed needs to contain references, not values $row[$field->name] = ""; $resultArray[$field->name] = &$row[$field->name]; + + if($field->type == 252) $longtext_exists = true; } $resultArray = array_merge(array($stmt), $resultArray); + if($longtext_exists) + { + mysqli_stmt_store_result($stmt); + } + call_user_func_array('mysqli_stmt_bind_result', $resultArray); $rows = array();