note 63605 deleted from function.mysql-query by bjori

From: Date: Sat, 25 Mar 2006 10:51:02 +0000
Subject: note 63605 deleted from function.mysql-query by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-106572@lists.php.net to get a copy of this message
Note Submitter: kerosuppi Reason: bad code ---- Mysql version of multi-query. Well treated the "';' inside quotes" case (I hope there is no bug!). <?php //mysql query (multi-query) function mysql_multi_query($querystr, $link = NULL) { //seperate the queries by ';' (but not ';' inside quotes) $pattern = "/((('([^\\\\']*(\\\\.)*)*'|". "\"([^\\\\\"]*(\\\\.)*)*\")+[^;'\"]*|". "[^;'\"]+('([^\\\\']*(\\\\.)*)*'|". "\"([^\\\\\"]*(\\\\.)*)*\")*)+)/s"; preg_match_all($pattern, $querystr, $out); $queries = $out[0]; foreach ($queries as $query) if(($query = trim($query)) != '') { if ($link == NULL) $result = mysql_query($query); else $result = mysql_query($query, $link); if(!result) return false; } return $result; //return last result } ?>

« previous php.notes (#106572) next »