diff --git a/inc/composer/class-command.php b/inc/composer/class-command.php index eaf0ab99..cbad9200 100644 --- a/inc/composer/class-command.php +++ b/inc/composer/class-command.php @@ -679,7 +679,11 @@ protected function db( InputInterface $input, OutputInterface $output ) { break; case 'exec': - $query = $input->getArgument( 'options' )[1] ?? null; + $options = $input->getArgument( 'options' ) ?? []; + array_shift( $options ); // remove the subcommand, we don't need it + $query = array_pop( $options ) ?: null; // the query is always the last option + $args = count( $options ) > 1 ? implode( ' ', $options ) : ''; // implode all optional options + if ( empty( $query ) ) { $output->writeln( 'No query specified: pass a query via `db exec -- "sql query..."`' ); break; @@ -688,7 +692,7 @@ protected function db( InputInterface $input, OutputInterface $output ) { $query = "$query;"; } // phpcs:ignore WordPress.WP.CapitalPDangit.Misspelled - passthru( "$base_command mysql --database=wordpress --user=root -e \"$query\"", $return_val ); + passthru( "$base_command mysql --database=wordpress --user=root $args -e \"$query\"", $return_val ); break; case null: // phpcs:ignore WordPress.WP.CapitalPDangit.Misspelled