|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65411 die() don't terminate the current script if mysqli::query use MYSQLI_USE_RESULT
Submitted: 2013-08-07 08:55 UTC Modified: 2013-08-07 14:36 UTC
From: tecdoc at ukr dot net Assigned:
Status: Not a bug Package: MySQLi related
PHP Version: Irrelevant OS: Windows 7 32bit
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: tecdoc at ukr dot net
New email:
PHP Version: OS:


 [2013-08-07 08:55 UTC] tecdoc at ukr dot net
Tested on PHP version is 5.4.16 and 5.3.13

die() don't terminate the current script when mysqli::query use MYSQLI_USE_RESULT

From manual page:

Test script:
$mysqli = new mysqli('localhost', 'root', '', 'db1');
if (!$mysqli->set_charset("utf8"))
    die('Set Charset Error: ' . $mysqli->error);

// tab - it is a table that have more than 3 000 000 rows
$q = "SELECT * FROM tab1";

// open query and try close all
$result = $mysqli->query($q, MYSQLI_USE_RESULT);
die('why don't terminated script?');

// this end of script don't terminate also
$result = $mysqli->query($q, MYSQLI_USE_RESULT);
$thread = $mysqli->thread_id;
die('why don't terminated script?');


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-08-07 10:04 UTC]
-Status: Open +Status: Not a bug
 [2013-08-07 10:04 UTC]
After fixing the error and escaping the ' in the die call 
   die('why don\'t terminated script?');
the script works as expected. I don't now what effect you see as "not terminating"
 [2013-08-07 11:59 UTC] tecdoc at ukr dot net
because you do script on table with small count of rows
do you try did script when table have more than 3 000 000 rows?
 [2013-08-07 14:27 UTC]
Why do you request lots of data if you don't use it?
 [2013-08-07 14:36 UTC] tecdoc at ukr dot net
I use this script.
I do export data from this big table in php. when export is doing i check some data and if this have some mistake it is need do die().

But i will find this bug. What problem abut how i use it

It is whole script
$mysqli = new mysqli('localhost', 'root', '', 'db1');

if ($mysqli->connect_error) 
    die('Connect Error (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error);

//Принудительная установка запросов и ответов БД в кодировку utf8
if (!$mysqli->set_charset("utf8"))
    die('Set Charset Error: ' . $mysqli->error);

// ну собсвенно получаем данные
$q = "SELECT * FROM tab1";
$result = $mysqli->query($q, MYSQLI_USE_RESULT);

// разбераем результат
$fp_csv = fopen("d:\\result\\nums-replace.csv", 'w');
$is_first = true;	// флаг - первый заход на разбор
while($row = $result->fetch_array(MYSQLI_ASSOC))
	$row['text'] = iconv("utf-8", "windows-1251", $row['text']); //кодировка
	if(!empty($row['datum'])) $row['datum'] = str_pad($row['entfalldatum'],8,'0'); //дата
	// запишем название колонок
		fputcsv($fp_csv, array_keys($row), ";");
		$is_first = false;

	//check field
		// !!!!!!!!!!!!!!!!!!!!!!
		die(); // DON'T TERMINATE

	fputcsv($fp_csv, $row, ";");

/* free result set */

/* close connection */
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon May 23 23:05:47 2022 UTC