mysqldump-php
mysqldump-php copied to clipboard
"If-not-exists" is not working, and missing documentation.
I am trying to add the "if-no-exists" parameter to the options array. The default value is "false" but the documentation is missing for the accepted parameters of the option...
I tried 'if-not-exists' => true
$dumpSettings = array('no-data' => true, 'if-not-exists' => true );
try {
$dump = new IMysqldump\Mysqldump('mysql:host='.$servername.';dbname='.$dbname, $username, $password, $dumpSettings);
$dump->start($save_path);
} catch (\Exception $e) {
echo 'mysqldump-php error: ' . $e->getMessage();
}
//Output: mysqldump-php error: Unexpected value in dumpSettings: (if-not-exists)
'if-not-exists' => true
The value doesn't matter. The check is just if ($this->dumpSettings['if-not-exists'] )
so anything not false will work. What matters is a correct typing. Sure you didn't mistyped anything? Try copy/paste from above.
Here is the full example of my code:
<?php
// composer autoloaded already
//including DB connection file to get password, servername etc
require project_root.'/src/php/helpers/connect_db.php';
$save_path = project_root.'/resources/installation/mysql_db_structure_backups/'.time().'.sql';
use Ifsnop\Mysqldump as IMysqldump;
$dumpSettings = array('no-data' => true, 'if-not-exists' => true );
try {
$dump = new IMysqldump\Mysqldump('mysql:host='.$servername.';dbname='.$dbname, $username, $password, $dumpSettings);
$dump->start($save_path);
} catch (\Exception $e) {
echo 'mysqldump-php error: ' . $e->getMessage();
}
//Output: mysqldump-php error: Unexpected value in dumpSettings: (if-not-exists)
But if I try: $dumpSettings = array('no-data' => true); and it's working fine...
Same problem here, the if-not-exists
setting is not available.
I had a quick look into this and it looks like the latest version "2.9" does not have the "if-not-exists" param added in.
See: https://github.com/ifsnop/mysqldump-php/compare/v2.9...master
Looks like it didn't make into the latest release. I will make a new one.