Skip to main content

Posts

Showing posts from September 10, 2009

Creates a backup of a MySQL in SQL format.

<?
if(!$res=mysql_connect('localhost','root',''))
{
echo "Error1";exit;
}

if(!$db=mysql_select_db('vision_old'))
{
echo "Error2";exit;
}
if (!function_exists('mysql_dump')) {
function mysql_dump1($database) {
$query = '';
$tables = @mysql_list_tables($database);
while ($row = @mysql_fetch_row($tables)) { $table_list[] = $row[0]; }
for ($i = 0; $i < @count($table_list); $i++) {
$results = mysql_query('DESCRIBE ' . $database . '.' . $table_list[$i]);
$query .= 'DROP TABLE IF EXISTS `' . $database . '.' . $table_list[$i] . '`;' . lnbr;
$query .= lnbr . 'CREATE TABLE `' . $database . '.' . $table_list[$i] . '` (' . lnbr;
$tmp = '';
while ($row = @mysql_fetch_assoc($results)) {
$query .= '`' . $row['Field'] . '` ' . $row['Type'];
if ($row['Null']…