mysqldump-php icon indicating copy to clipboard operation
mysqldump-php copied to clipboard

"If-not-exists" is not working, and missing documentation.

Open halid96 opened this issue 3 years ago • 4 comments

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)

halid96 avatar May 27 '21 15:05 halid96

'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.

phpony avatar May 27 '21 15:05 phpony

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...

halid96 avatar May 27 '21 16:05 halid96

Same problem here, the if-not-exists setting is not available.

contrid avatar Jun 23 '21 11:06 contrid

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

jcbjoe avatar Mar 25 '22 15:03 jcbjoe

Looks like it didn't make into the latest release. I will make a new one.

ifsnop avatar Feb 09 '23 02:02 ifsnop