note 114100 added to mysqli.multi-query

From: Date: Fri, 10 Jan 2014 20:13:15 +0000
Subject: note 114100 added to mysqli.multi-query
Groups: php.notes 
Request: Send a blank email to php-notes+get-198198@lists.php.net to get a copy of this message
I appreciate the advice from crmccar at gmail dot com regarding the proper way to check for errors, but I would get an error with his/her code. I fixed it by changing the code a little: <?php $sql = file_get_contents( 'sql/test_' . $id . '_data.sql'); $query_array = explode(';', $sql); // Run the SQL $i = 0; if( $this->mysqli->multi_query( $sql ) ) { do { $this->mysqli->next_result(); $i++; } while( $this->mysqli->more_results() ); } if( $this->mysqli->errno ) { die( '<h1>ERROR</h1> Query #' . ( $i + 1 ) . ' of <b>test_' . $id . '_data.sql</b>:<br /><br /> <pre>' . $query_array[ $i ] . '</pre><br /><br /> <span style="color:red;">' . $this->mysqli->error . '</span>' ); } ?> ---- Server IP: 72.52.91.14 Probable Submitter: 72.52.91.14 ---- Manual Page -- http://php.net/manual/en/mysqli.multi-query.php Edit -- https://master.php.net/note/edit/114100 Del: integrated -- https://master.php.net/note/delete/114100/integrated Del: useless -- https://master.php.net/note/delete/114100/useless Del: bad code -- https://master.php.net/note/delete/114100/bad+code Del: spam -- https://master.php.net/note/delete/114100/spam Del: non-english -- https://master.php.net/note/delete/114100/non-english Del: in docs -- https://master.php.net/note/delete/114100/in+docs Del: other reasons-- https://master.php.net/note/delete/114100 Reject -- https://master.php.net/note/reject/114100 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#198198) next »