note 18583 deleted from function.mysql-query by didou
| From: | didou@php.net | Date: | Sun, 18 May 2003 00:46:14 +0000 |
| Subject: | note 18583 deleted from function.mysql-query by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-48298@lists.php.net to get a copy of this message | ||
Note Submitter: mars@planet-d.net
----
it seems php's mysql_query does handle multiple queries at the same time, but only returns a
boolean value even if the last request is a select... phpmyadmin which uses mysql_query a lot has
this behaviour too.
so i wrote this function to solve this problem
function sendquery( $db_host, $db_base, $db_user, $db_pw, $query )
{
$mess = 'Connexion with server ' . $db_host . ' failed';
mysql_connect( $db_host, $db_user, $db_pw ) or die( errorhandle($mess));
mysql_select_db( $db_base ) or die( errorhandle($mess));
$array = explode( ';', $query );
foreach( $array as $value )
{
if( !$result = mysql_query( $value ))
break;
}
return $result;
}
i hope this helps.