note 49385 deleted from function.mysql-query by cece
| From: | cece@php.net | Date: | Wed, 26 Jan 2005 11:32:08 +0000 |
| Subject: | note 49385 deleted from function.mysql-query by cece | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-84016@lists.php.net to get a copy of this message | ||
Note Submitter: alex_ndc at yahoo dot com
Reason: bad code
----
Here is a multiple query function that takes the char ; as a delimiter. Also, the splitting of the
query is done by a regular expression, so it doesn't matter if the character ; appears slashed
in a sql command:
<?php
function multipleQuery($query)
{
// spliting the query
$queryArray = preg_split(
'/(?<![;\\\\])'.
'(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'.
'|\\\\\\\\\\\\\\\\\\\\\\\\;'.
'|\\\\\\\\\\\\\\\\;|\\\\\\\\;|;)/'
,$query);
foreach ($queryArray AS $query) {
$query = trim($query);
if (!empty($query)) {
mysql_query($query, $link);
if (mysql_error($link))
trigger_error('<B>MYSQL ERROR -</B> '.mysql_errno($link).'
'.mysql_error($link).
'<BR/><B>SQL:</B>'.$query, E_USER_ERROR);
}
}
}
?>