@@ -539,6 +539,9 @@ public function export( $args, $assoc_args ) {
539
539
* [--dbpass=<value>]
540
540
* : Password to pass to mysql. Defaults to DB_PASSWORD.
541
541
*
542
+ * [--<field>=<value>]
543
+ * : Extra arguments to pass to mysqldump. [Refer to mysqldump docs](https://dev.mysql.com/doc/en/mysqldump.html#mysqldump-option-summary).
544
+ *
542
545
* [--skip-optimization]
543
546
* : When using an SQL file, do not include speed optimization such as disabling auto-commit and key checks.
544
547
*
@@ -555,10 +558,7 @@ public function import( $args, $assoc_args ) {
555
558
$ result_file = sprintf ( '%s.sql ' , DB_NAME );
556
559
}
557
560
558
- $ mysql_args = array (
559
- 'database ' => DB_NAME ,
560
- );
561
- $ mysql_args = array_merge ( self ::get_dbuser_dbpass_args ( $ assoc_args ), $ mysql_args );
561
+ $ assoc_args ['database ' ] = DB_NAME ;
562
562
563
563
if ( '- ' !== $ result_file ) {
564
564
if ( ! is_readable ( $ result_file ) ) {
@@ -569,10 +569,14 @@ public function import( $args, $assoc_args ) {
569
569
? 'SOURCE %s; '
570
570
: 'SET autocommit = 0; SET unique_checks = 0; SET foreign_key_checks = 0; SOURCE %s; COMMIT; ' ;
571
571
572
- $ mysql_args ['execute ' ] = sprintf ( $ query , $ result_file );
572
+ if ( isset ( $ assoc_args ['skip-optimization ' ] ) ) {
573
+ unset( $ assoc_args ['skip-optimization ' ] );
574
+ }
575
+
576
+ $ assoc_args ['execute ' ] = sprintf ( $ query , $ result_file );
573
577
}
574
578
575
- self ::run ( '/usr/bin/env mysql --no-defaults --no-auto-rehash ' , $ mysql_args );
579
+ self ::run ( '/usr/bin/env mysql --no-defaults --no-auto-rehash ' , $ assoc_args );
576
580
577
581
WP_CLI ::success ( sprintf ( "Imported from '%s'. " , $ result_file ) );
578
582
}
@@ -1025,10 +1029,10 @@ public function prefix() {
1025
1029
* | 98 | foo_options | a:1:{s:12:"_multiwidget";i:1;} | yes |
1026
1030
* | 99 | foo_settings | a:0:{} | yes |
1027
1031
* +----+--------------+--------------------------------+-----+
1028
- *
1032
+ *
1029
1033
* # SQL search and delete records from database table 'wp_options' where 'option_name' match 'foo'
1030
1034
* wp db query "DELETE from wp_options where option_id in ($(wp db query "SELECT GROUP_CONCAT(option_id SEPARATOR ',') from wp_options where option_name like '%foo%';" --silent --skip-column-names))"
1031
- *
1035
+ *
1032
1036
* @when after_wp_load
1033
1037
*/
1034
1038
public function search ( $ args , $ assoc_args ) {
0 commit comments