equal
deleted
inserted
replaced
|
1 <?php |
|
2 |
|
3 // MySQL utility script. |
|
4 |
|
5 if ( $argc < 2 ) |
|
6 die("Usage: {$argv[0]} port username password"); |
|
7 |
|
8 $user = $argv[2]; |
|
9 $pass = $argv[3]; |
|
10 $handle = mysql_connect("localhost:{$argv[1]}", $user, $pass); |
|
11 if ( !$handle ) |
|
12 { |
|
13 echo "MySQL authentication failed."; |
|
14 exit(1); |
|
15 } |
|
16 |
|
17 if ( !empty($argv[4]) ) |
|
18 { |
|
19 $queries = explode(';', $argv[4]); |
|
20 foreach ( $queries as $query ) |
|
21 { |
|
22 $query = trim($query); |
|
23 if ( empty($query) ) |
|
24 continue; |
|
25 echo "$query;\n"; |
|
26 if ( !mysql_query("$query;") ) |
|
27 exit(1); |
|
28 } |
|
29 } |
|
30 |
|
31 exit(0); |