I have code as
$db_name = "db";
$outputfile = "/somewhere";
$new_db_name = 'newdb';
$cmd = 'mysqldump --skip-triggers %s > %s 2>&1';
$cmd = sprintf($cmd, escapeshellarg($db_name), escapeshellcmd($output_file));
exec($cmd, $output, $ret);
if ($ret !=0 ) {
//log error message in $output
}
Then to import:
$cmd = 'mysql --database=%s < %s 2>&1';
$cmd = sprintf($cmd, escapeshellarg($new_db_name), escapeshellcmd($output_file));
exec($cmd, $output, $ret);
//etc.
unlink($outputfile);
But here what should i do to get the export query, rather than creating a file everytime?
EDITED:
IN THE RESPONSE OF REPLY OF MATT
- I am using Windows, will the code u have given work as I am not sure the code I already have will work in Windows as it seems to be linux commands?
- Its my need to script in PHP its the process which is going to be triggered when installing a component in joomla
- What is PIPE in PHP?