-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
48 lines (44 loc) · 821 Bytes
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
include_once "lib/parsesql.php";
$file = "parsesql.sql";
$host = "localhost";
$user = "root";
$password = "";
$database = "database";
mysql_connect($host, $user, $password);
mysql_select_db($database);
$query_array = ParseSQL(file_get_contents($file));
$sql = "start transaction";
$res = mysql_query($sql);
$oke = 1;
$nqueryall = 0;
$nquerysuccess = 0;
$nqueryfail = 0;
foreach($query_array as $key=>$query)
{
$sql = $query['query'];
$res = mysql_query($sql);
if(!$res)
{
$oke = $oke * 0;
$nqueryfail++;
}
else
{
$nquerysuccess++;
}
$nqueryall++;
}
if($oke)
{
$sql = "commit";
$res = mysql_query($sql);
echo "Commit. Success execute $nquerysuccess queries.";
}
else
{
$sql = "rollback";
$res = mysql_query($sql);
echo "Rollback. $nqueryfail of $nqueryall queries fail to be executed.";
}
?>