List Info

Thread: note 71465 added to function.mysqli-multi-query




note 71465 added to function.mysqli-multi-query
user name
2006-11-30 06:47:07
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: %sn",
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-q
uery.php
Edit        -- https://master
.php.net/note/edit/71465
Del: integrated  -- h
ttps://master.php.net/note/delete/71465/integrated
Del: useless     -- http
s://master.php.net/note/delete/71465/useless
Del: bad code    -- htt
ps://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     -- http
s://master.php.net/note/delete/71465/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/71465
Reject      -- https://mast
er.php.net/note/reject/71465
Search      -- https://
master.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )