note 94318 added to mysqli.next-result

From: Date: Wed, 28 Oct 2009 19:24:24 +0000
Subject: note 94318 added to mysqli.next-result
Groups: php.notes 
Request: Send a blank email to php-notes+get-162204@lists.php.net to get a copy of this message
Stored procedures few rowset example: some_file.php <?php function proc() { global $global; $db_connect_list = array('site'); SQLinit($db_connect_list); if(isset($global['error'])){return;} SQL('CALL procedure();'); while($row=mysqli_fetch_assoc($global['result'])){ // do some } SQLnext(); while($row=mysqli_fetch_assoc($global['result'])){ // do some } SQLnext(); while($row=mysqli_fetch_assoc($global['result'])){ // do some } SQLclose($db_connect_list); } ?> config.php <?php $global['sys']['db']['site'] = array('host'=>'localhost', 'user'=>'site', 'pass'=>''); ?> engine.php <?php function SQLinit($array_list){ global $global; foreach($array_list as $set){ if(!$global['sys']['db'][$set]['connect'] = mysqli_connect( $global['sys']['db'][$set]['host'], $global['sys']['db'][$set]['user'], $global['sys']['db'][$set]['pass'])){ $global['error']['code'] = 500; $global['error']['text'] = 'Database not avaliable'; $w=fopen('error.log','a+'); fwrite($w,'time: '.date('Y M d H:i:s')."\r\n"); fwrite($w,'errno: '.mysqli_connect_errno()."\r\n"); fwrite($w,'error: '.mysqli_connect_error()."\r\n"); fclose($w); return; } if(!isset($global['sys']['default_connect'])) $global['sys']['default_connect'] = $global['sys']['db'][$set]['connect']; SQL('SET NAMES \'utf8\' COLLATE \'utf8_unicode_ci\';', $global['sys']['db'][$set]['connect']); SQL('SET CHARACTER SET \'utf8\';', $global['sys']['db'][$set]['connect']); SQL('SET character_set_connection = \'utf8\';', $global['sys']['db'][$set]['connect']); } } function mTime(){ list($usec, $sec) = explode(" ", microtime()); return ((float)$usec+(float)$sec); } function SQL($sql, $connect = -1){ global $global; if($connect === -1)$connect = $global['sys']['default_connect']; if(isset($global['error']['sql']))return; while ($connect->next_result()) $connect->store_result(); $begin=mTime(); $global['result']=mysqli_query($connect, $sql); $end=mTime(); $global['sys']['time_sql']+=$end-$begin; $error=mysqli_error($connect); if($error!=''){ $global['error']['code'] = 502; $global['error']['text'] = 'SQL error'; $global['error']['sql'] = true; $w=fopen('error.log','a+'); fwrite($w,'time: '.date('Y M d H:i:s')."\r\n"); fwrite($w,'errno: '.mysqli_errno($connect)."\r\n"); fwrite($w,'error: '.$error."\r\n"); fwrite($w,'sql: '.$sql."\r\n"); fclose($w); }else{ $w=fopen('sql.log','a+'); fwrite($w,'time: '.date('Y M d H:i:s')."\r\n"); fwrite($w,'sql: '.$sql."\r\n"); fclose($w); } } function SQLnext($connect = -1){ global $global; if($connect === -1)$connect = $global['sys']['default_connect']; if(isset($global['error']['sql']))return; $connect->next_result(); $global['result'] = $connect->store_result(); } function SQLclose($array_list){ global $global; foreach($array_list as $set){ mysqli_close($global['sys']['db'][$set]['connect']); } } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 92.112.110.245 ---- Manual Page -- http://www.php.net/manual/en/mysqli.next-result.php Edit -- https://master.php.net/note/edit/94318 Del: integrated -- https://master.php.net/note/delete/94318/integrated Del: useless -- https://master.php.net/note/delete/94318/useless Del: bad code -- https://master.php.net/note/delete/94318/bad+code Del: spam -- https://master.php.net/note/delete/94318/spam Del: non-english -- https://master.php.net/note/delete/94318/non-english Del: in docs -- https://master.php.net/note/delete/94318/in+docs Del: other reasons-- https://master.php.net/note/delete/94318 Reject -- https://master.php.net/note/reject/94318 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#162204) next »