note 18583 added to function.mysql-query
| From: | mars at planet-d dot net | Date: | Mon, 28 Jan 2002 16:39:19 +0000 |
| Subject: | note 18583 added to function.mysql-query | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-25926@lists.php.net to get a copy of this message | ||
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.
--
http://www.php.net/manual/en/function.mysql-query.php
http://master.php.net/manage/user-notes.php?action=edit+18583
http://master.php.net/manage/user-notes.php?action=delete+18583
http://master.php.net/manage/user-notes.php?action=reject+18583