<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<META HTTP-EQUIV="Expires" CONTENT="Tue, 01 Dec 1990 06:30:00 GMT">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<title>Init/Create the DB</title>
</head>
<body>
Query# <div name=i id=i style="font-weight:bold;"></div>
Query: <div name=q id=q style="font-weight:bold;"></div>
<small>
<?php
//init.php
//create the database
include 'databaseinc.php';
//hosting site already has already created the DB
// mysql_create_db($db, $link);
// mysql_select_db($db, $link) or die("db select error: " . mysql_error() .
"<a href=\"kamaniki.php\">Admin Page</a>, <a href=\"index.html\">Main
page</a>");
//read the whole SQL dump file.
//eliminate comments first
$s = file_get_contents("import.sql");
$s = preg_replace($s,"\/\*.*\/\*"); //remove block comments. not a very good
attempt.
$s = preg_replace($s,"^\#.*$"); //remove single-line comments
$a = explode(";",$s);
for ($x=0; $x<count($a); $x++) {
$a[$x]=ltrim(rtrim($a[$x]));
echo "<script>i.innerHTML=$x;q.innerHTML=\"" . addslashes($a[$x]) .
"\";</script>";
if ($a != "" && $a != "\n") {
mysql_query($a) or die("query error: <b>" . mysql_error() . "</b><a
href=\"index.html\">Main page</a>");
}
}
echo "Success...<a href=\"index.html\">Main page</a>";
?>
</small>
</body>
</html>
I created this a while back in the need for database initialization, when
admins had not installed PHPMyAdmin.
"Jim Michaels" <jm******@nospam.yahoo.com> wrote in message
news:Yt********************@comcast.com...
"Dikkie Dik" <no****@nospam.org> wrote in message
news:63***************************@news.versatel.n l... First of all, you'd better ask in comp.databases.mysql
You can insert more than one row with an insert command:
INSERT INTO tblname(...)
VALUES(...),
(...),
(...);
and in MySQL, you are limited to about I think 1MB per insert.(?) so you
must do it in chunks if it's big.
Depending on the engine used, you could send it without being interested
in the result:
see http://dev.mysql.com/doc/refman/4.1/...t-delayed.html
Best regards
Chameleon wrote: I have a SQL Script with about 5000 SQL Commands.
How can I send it to SQL Server at once?
I see mysql_query() fails on first semicolon (;) who delimits the SQL
Commands.
Another question:
I send to a MySQL server via fast Internet connection, about 500 INSERT
commands one by one via mysql_query().
It takes much time. Why?
I suspect that, mysql_query() after send the query to server, waits for
a "OK" response. If it's true, how can I send and send and send SQL
commands and MySQL server reply "OK" after send all these things?
(or no wait at all?)