« 2012 . 05 »    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

MYSQLをPHPからDUMPする方法 

PHPからテーブル単位でDumpできて、圧縮までできちゃううぐれもの


MYSQLDumpをダウンロード
http://www.coders4fun.com/en/category/mysql/

//Include the library
@include_once('lib_dump.php');
//Db connection
$connection = @mysql_connect('127.0.0.1','username','password');
//Create the MySQLDump class instance
//1° parameter: db name
//2° parameter: the exported file that will contain the dump
//3° parameter: create zipped file (true = zipped, false = normal)
//4° parameter: data encode (true = hexadecimal, false = plain text)
$dumper = new MySQLDump('mydb','dumpfile.sql',false,false);
//Structure export of the table 'mytable'
$dumper->getTableStructure('mytable');
//Data export of the table 'mytable'
$dumper->getTableData('mytable');

$connectionの127.0.0.1はlocalhostにする必要があるかも

Comment

Post a comment















管理者にだけ表示を許可する

Trackbacks

この記事のトラックバックURL
→http://flamberge12.blog43.fc2.com/tb.php/35-251ae680