Database . '';
}
$r.=$t->inputP("Existing databases: ".implode(', ',$db_array));
if (!in_array($db_name, $db_array)) {
$str.=$t->inputP("Creating database $db_name
...");
$db = mysql_query("CREATE DATABASE $db_name;", $mysql);
if ($db===FALSE) {
$str.=$t->inputP("Database $db_name
".
"could not be created: ".
mysql_error($mysql), true);
return false;
}
}
$r.=$t->inputP("Selecting database $db_name
...");
$db = mysql_select_db($db_name, $mysql);
if (!$db) {
$r.=$t->inputP('Could not select database: ',
mysql_error($mysql), true);
return false;
}
return true;
} else {
return false;
}
}
function mm_mysql_count_rows_in_table($mysql, $table_name) {
$table=mysql_real_escape_string($table_name);
$query =
"SELECT COUNT(*)\n".
"FROM $table;";
$total = mysql_query($query, $mysql);
$total = mysql_fetch_array($total);
$total = $total[0];
return $total;
}
function mm_mysql_table_exists($mysql, $table_name) {
$table=mysql_real_escape_string($table_name);
$query =
"SELECT COUNT(*)\n".
"FROM information_schema.tables\n".
"WHERE table_name = '$table';";
$total = mysql_query($query, $mysql);
$total = mysql_fetch_array($total);
$total = $total[0];
return $total>0;
}
function mm_mysql_create_table($mysql, $table_name, $columns) {
$table_exists = mm_mysql_table_exists($mysql, $table_name);
if ($table_exists) {
return 0;
}
$query ="CREATE TABLE $table_name (\n";
$query.=implode(",\n ", $columns);
$query.="\n);";
$success = mysql_query($query);
if (!$success) {
return mysql_error($mysql);
}
return 1;
}