note 71465 added to function.mysqli-multi-query

From: Date: Thu, 30 Nov 2006 06:47:07 +0000
Subject: note 71465 added to function.mysqli-multi-query
Groups: php.notes 
Request: Send a blank email to php-notes+get-120179@lists.php.net to get a copy of this message
I was developing my own CMS and I was having problem with attaching the database' sql file. I thought mysqli_multi_query got bugs where it crashes my MySQL server. I tried to report the bug but it showed that it has duplicate bug reports of other developers. To my surprise, mysqli_multi_query needs to bother with result even if there's none. I finally got it working when I copied the sample and removed somethings. Here is what it looked liked <?php $link = mysqli_connect("localhost", "my_user", "my_password", "world"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $query = "CREATE TABLE....;...;... blah blah blah;..."; /* execute multi query */ if (mysqli_multi_query($link, $query)) { do { /* store first result set */ if ($result = mysqli_store_result($link)) { //do nothing since there's nothing to handle mysqli_free_result($result); } /* print divider */ if (mysqli_more_results($link)) { //I just kept this since it seems useful //try removing and see for yourself } } while (mysqli_next_result($link)); } /* close connection */ mysqli_close($link); ?> bottom-line: I think mysql_multi_query should only be used for attaching a database. it's hard to handle results from 'SELECT' statements inside a single while loop. ---- Server IP: 203.220.0.234 Probable Submitter: 124.217.68.208 ---- Manual Page -- http://www.php.net/manual/en/function.mysqli-multi-query.php Edit -- https://master.php.net/note/edit/71465 Del: integrated -- https://master.php.net/note/delete/71465/integrated Del: useless -- https://master.php.net/note/delete/71465/useless Del: bad code -- https://master.php.net/note/delete/71465/bad+code Del: spam -- https://master.php.net/note/delete/71465/spam Del: non-english -- https://master.php.net/note/delete/71465/non-english Del: in docs -- https://master.php.net/note/delete/71465/in+docs Del: other reasons-- https://master.php.net/note/delete/71465 Reject -- https://master.php.net/note/reject/71465 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#120179) next »