CentOS 6.4 PHP 5.3.3 MySQL 5.1.69 x86_64
mysql_stmt::fetch()
When fetching using a prepared statement, PHP gives an error: PHP Fatal error: allowable memory size of 134217728 bytes has been exhausted (tried to allocate 4294967296 bytes).
This happens when the variable included in the SELECT statement used to create the temporary table is not set, regardless of whether the variable was set differently in the environment before the stored procedure was called. The variable must be set in the stored procedure. When the SELECT statement is used to return data to a temporary table to PHP, and PHP uses mysql_stmt :: fetch () to access the data, PHP generates the fatal error described above.
MySQL code:
DELIMITER $$ CREATE PROCEDURE test_sp() BEGIN
PHP code:
// obtain MySQL login info require_once(MYSQLOBJ); // initialize status $status = ""; $db = new mysqli( DB_HOST, DB_USER, DB_PASSWORD, DB_NAME ); $query = "CALL test_sp"; $stmt = $db->prepare($query); $stmt->execute(); $stmt->bind_result( $status ); $stmt->store_result(); $stmt->fetch(); // PHP FATAL ERROR OCCURS HERE $stmt->free_result(); $db->close(); print "<p>status = $status</p>\n";
source share