note 55811 added to function.mysql-query
| From: | ix at nivelzero dot ro | Date: | Sun, 14 Aug 2005 10:07:37 +0000 |
| Subject: | note 55811 added to function.mysql-query | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-93580@lists.php.net to get a copy of this message | ||
here's a script for parsing a *.sql file (tested only on dumps created with phpMyAdmin) which
is short and simple (why do people say "here's a short and simple script" and it has
a 100 lines?). the script skips comments and allows ; to be present within the querys
<?php
function parse_mysql_dump($url){
$file_content = file($url);
$query = "";
foreach($file_content as $sql_line){
if(trim($sql_line) != "" && strpos($sql_line, "--") === false){
$query .= $sql_line;
if(preg_match("/;[\040]*\$/", $sql_line)){
$result = mysql_query($query)or die(mysql_error());
$query = "";
}
}
}
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.mysql-query.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55811
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55811&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55811&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55811&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55811&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55811&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55811&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55811&report=yes
Search -- http://master.php.net/manage/user-notes.php