Skip to content

Commit a5ab2b7

Browse files
committed
Add option to disable database creation statement. Fixes #232
1 parent de94701 commit a5ab2b7

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ $dumpSettingsDefault = array(
189189
'insert-ignore' => false,
190190
'net_buffer_length' => self::MAXLINESIZE,
191191
'no-autocommit' => true,
192+
'no-create-db' => false,
192193
'no-create-info' => false,
193194
'lock-tables' => true,
194195
'routines' => false,
@@ -264,6 +265,9 @@ $this->_dumpSettings = self::array_replace_recursive($dumpSettingsDefault, $dump
264265
- **no-autocommit**
265266
- Option to disable autocommit (faster inserts, no problems with index keys)
266267
- https://dev.mysql.com/doc/refman/4.1/en/commit.html
268+
- **no-create-db**
269+
- Option to disable the dump of create database statements.
270+
- https://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_no-create-db
267271
- **no-create-info**
268272
- https://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_no-create-info
269273
- **no-data**

src/Ifsnop/Mysqldump/Mysqldump.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ class Mysqldump
138138
'insert-ignore' => false,
139139
'net_buffer_length' => self::MAXLINESIZE,
140140
'no-autocommit' => true,
141+
'no-create-db' => false,
141142
'no-create-info' => false,
142143
'lock-tables' => true,
143144
'routines' => false,
@@ -1852,6 +1853,10 @@ class TypeAdapterMysql extends TypeAdapterFactory
18521853

18531854
public function databases()
18541855
{
1856+
if ($this->dumpSettings['no-create-db']) {
1857+
return "";
1858+
}
1859+
18551860
$this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
18561861
$args = func_get_args();
18571862
$databaseName = $args[0];

0 commit comments

Comments
 (0)