inst-resources/mysqlutil.php
author Neal Gompa <neal@enanocms.org>
Fri, 18 Dec 2009 19:16:05 -0600
changeset 8 af10a4dbafb4
parent 0 67e1cc6cd929
permissions -rw-r--r--
Commenting out plugin component blocks. We aren't using them for anything, and they are currently empty anyway...
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
     1
<?php
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
     2
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
     3
// MySQL utility script.
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
     4
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
     5
if ( $argc < 2 )
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
     6
  die("Usage: {$argv[0]} port username password");
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
     7
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
     8
$user = $argv[2];
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
     9
$pass = $argv[3];
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    10
$handle = mysql_connect("localhost:{$argv[1]}", $user, $pass);
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    11
if ( !$handle )
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    12
{
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    13
  echo "MySQL authentication failed.";
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    14
  exit(1);
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    15
}
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    16
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    17
if ( !empty($argv[4]) )
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    18
{
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    19
  $queries = explode(';', $argv[4]);
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    20
  foreach ( $queries as $query )
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    21
  {
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    22
    $query = trim($query);
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    23
    if ( empty($query) )
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    24
      continue;
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    25
    echo "$query;\n";
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    26
    if ( !mysql_query("$query;") )
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    27
      exit(1);
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    28
  }
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    29
}
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    30
67e1cc6cd929 First commit. It's working!
Dan
parents:
diff changeset
    31
exit(0);