ifsnop / mysqldump-php

PHP version of mysqldump cli that comes with MySQL
https://github.com/ifsnop/mysqldump-php
GNU General Public License v3.0
1.25k stars 300 forks source link

How to use options ? #216

Closed CouinCouin closed 3 years ago

CouinCouin commented 3 years ago

Hi,

I found your script that could answer to my needings (run with old php 5.5 and more recent 7, and SQL5.7 Database), but I would dump only one table.

I don't find how to use options (especially 'include-tables') .

Tried this code :

include_once('Mysqldump.php');
$dumpSettings = array(
'include-tables' => array('songs'),
'add-drop-table' => true,
);

$dump = new Ifsnop\Mysqldump\Mysqldump("mysql:host=$dyndnsrdjtitou;dbname=$dbaserdj", $dbuserrdj, $dbpwrdj);
$dump->start('songs.sql');

But it dumps the whole database.

could you please help me ?

Thanks and happy new year :) Couin

garas commented 3 years ago

Read https://github.com/ifsnop/mysqldump-php/wiki/Full-usage-example

ifsnop commented 3 years ago

Tried this code :

include_once('Mysqldump.php'); $dumpSettings = array( 'include-tables' => array('songs'), 'add-drop-table' => true, ); $dump = new Ifsnop\Mysqldump\Mysqldump("mysql:host=$dyndnsrdjtitou;dbname=$dbaserdj", $dbuserrdj, $dbpwrdj); $dump->start('songs.sql');

But it dumps the whole database.

could you please help me ?

Hi there!

Looks like you forgot to add $dumpSettings to the constructor call (after $dbpwrdj).

Please have a look at the examples.

Kind regards and happy New Year!

CouinCouin commented 3 years ago

Hi,

It's ok after adding $dumpSettings after $dbpwrdj :)

Thanks,