{"id":342,"date":"2002-04-11T10:50:35","date_gmt":"2002-04-11T15:50:35","guid":{"rendered":"http:\/\/www.ashleyit.com\/blogs\/brentashley\/?p=342"},"modified":"2007-11-01T08:45:13","modified_gmt":"2007-11-01T13:45:13","slug":"multiple-mysql-queries-in-one-call","status":"publish","type":"post","link":"https:\/\/ashleyit.com\/blogs\/brentashley\/2002\/04\/11\/multiple-mysql-queries-in-one-call\/","title":{"rendered":"Multiple MySQL queries in one call"},"content":{"rendered":"<p>[Note &#8211; this post was written in 2002.  Things have changed since then &#8211; check your docs]<\/p>\n<p>What the hell good is a sql call that is limited to a single query?  I find that PHP&#8217;s mysql_query() won&#8217;t take multiple statements.  Makes for some unnecessarily wordy code.  I found a good snippet in <a href=\"http:\/\/www.php.net\/manual\/en\/function.mysql-query.php\">PHP.net&#8217;s online manual <\/a>annotations, though&#8230;<br \/>\n<!--more--><br \/>\nmars@planet-d.net<br \/>\n28-Jan-2002 11:39 <\/p>\n<p>it seems php&#8217;s mysql_query does handle multiple queries at the same time,<br \/>\nbut only returns a boolean value even if the last request is a select&#8230;<br \/>\nphpmyadmin which uses mysql_query a lot has this behaviour too.<\/p>\n<p>so i wrote this function to solve this problem<\/p>\n<p>function sendquery( $db_host, $db_base, $db_user, $db_pw, $query )<br \/>\n{<br \/>\n&nbsp;&nbsp;$mess = &#8216;Connexion with server &#8216; . $db_host . &#8216; failed&#8217;;<br \/>\n&nbsp;&nbsp;mysql_connect( $db_host, $db_user, $db_pw ) or die( errorhandle($mess));<br \/>\n&nbsp;&nbsp;mysql_select_db( $db_base ) or die( errorhandle($mess));<\/p>\n<p>&nbsp;&nbsp;$array = explode( &#8216;;&#8217;, $query );<br \/>\n&nbsp;&nbsp;foreach( $array as $value )<br \/>\n&nbsp;&nbsp;{<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;if( !$result = mysql_query( $value ))<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br \/>\n&nbsp;&nbsp;}<br \/>\n&nbsp;&nbsp;return $result;<br \/>\n}<\/p>\n<p>i hope this helps.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[Note &#8211; this post was written in 2002. Things have changed since then &#8211; check your docs] What the hell good is a sql call that is limited to a single query? I find that PHP&#8217;s mysql_query() won&#8217;t take multiple statements. Makes for some unnecessarily wordy code. I found a good snippet in PHP.net&#8217;s online [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"activitypub_content_warning":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-342","post","type-post","status-publish","format-standard","hentry","category-blather"],"_links":{"self":[{"href":"https:\/\/ashleyit.com\/blogs\/brentashley\/wp-json\/wp\/v2\/posts\/342","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ashleyit.com\/blogs\/brentashley\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ashleyit.com\/blogs\/brentashley\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ashleyit.com\/blogs\/brentashley\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ashleyit.com\/blogs\/brentashley\/wp-json\/wp\/v2\/comments?post=342"}],"version-history":[{"count":0,"href":"https:\/\/ashleyit.com\/blogs\/brentashley\/wp-json\/wp\/v2\/posts\/342\/revisions"}],"wp:attachment":[{"href":"https:\/\/ashleyit.com\/blogs\/brentashley\/wp-json\/wp\/v2\/media?parent=342"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ashleyit.com\/blogs\/brentashley\/wp-json\/wp\/v2\/categories?post=342"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ashleyit.com\/blogs\/brentashley\/wp-json\/wp\/v2\/tags?post=342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}