|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-08-07 08:55 UTC] tecdoc at ukr dot net
Description: ------------ 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: http://www.php.net/mysqli.query#refsect1-mysqli.query-seealso --- 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); $result->free(); $mysqli->close(); die('why don't terminated script?'); // this end of script don't terminate also $result = $mysqli->query($q, MYSQLI_USE_RESULT); $result->free(); $thread = $mysqli->thread_id; $mysqli->kill($thread); $mysqli->close(); die('why don't terminated script?'); PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 08 01:00:02 2025 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"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 --------------------- <?php $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); set_time_limit(0); // // ну собсвенно получаем данные $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'); //дата // запишем название колонок if($is_first){ fputcsv($fp_csv, array_keys($row), ";"); $is_first = false; } //check field if(empty($row['index'])) // !!!!!!!!!!!!!!!!!!!!!! die(); // DON'T TERMINATE fputcsv($fp_csv, $row, ";"); } fclose($fp_csv); /* free result set */ $result->free(); /* close connection */ $mysqli->close(); ?>