note 49629 added to function.mysql-query

From: Date: Thu, 03 Feb 2005 11:34:19 +0000
Subject: note 49629 added to function.mysql-query
Groups: php.notes 
Request: Send a blank email to php-notes+get-84429@lists.php.net to get a copy of this message
Based on Predrag Supurovic mysql_exec_batch function. Useful if your queries contains html code with ; characters The input must be an array() with queries inserted with array_unshift() or similar. $p_query acts as an STACK!!. function mysql_exec_batch2 ($p_query, $p_transaction_safe = true) { if (!is_array($p_query)){ echo("<br><br><b>Error: input is not ARRAY</b><br><br>\n");//////////////////// return; } if ($p_transaction_safe) array_push($p_query,'START TRANSACTION'); while(sizeof($p_query)>0){ $query= array_pop($p_query); $result= mysql_query($query) or die("function mysql_exec_batch ERROR ".mysql_error()); if($result==0) break; } if($p_transaction_safe){ if ($result!=0){ $result= mysql_query('COMMIT'); } else{ $result= mysql_query('ROLLBACK'); } } return $result; } ---- Manual Page -- http://www.php.net/manual/en/function.mysql-query.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+49629 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49629&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49629&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49629&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49629&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49629&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+49629&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#84429) next »