18 wrz 2009

Dump i import tabeli mysql w php

dump:

$command = 'mysqldump -h localhost -B baza -u user -phaslo --tables Panstwa --no-create-info --skip-lock-tables --compact --comments --complete-insert > /data/dump/Panstwa.sql 2> /data/dump/err_Panstwa.txt';
exec($command);

import:

$command = 'mysql -h localhost -B baza -u user -phaslo --default-character-set=utf8 < /data/dump/Panstwa.sql';
exec($command);

kopiownie:

$sql = 'INSERT INTO Panstwa SELECT * FROM b_Panstwa';
mysql_query($sql);