need export query rather than creating file for mysqldump without triggers.. See description

Posted by OM The Eternity on Stack Overflow See other posts from Stack Overflow or by OM The Eternity
Published on 2010-05-05T05:16:00Z Indexed on 2010/05/05 5:28 UTC
Read the original article Hit count: 154

Filed under:
|
|
|
|

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);

Bow here what should i do to get the export query, rather than creating a file everytime?

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql