Skip to content

Commit 05263c3

Browse files
committed
Rename and reorder the columns
1 parent 1c9b2e8 commit 05263c3

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/DB_Command.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,12 +1484,16 @@ public function search( $args, $assoc_args ) {
14841484

14851485
if ( $format ) {
14861486
$search_results[] = [
1487-
'table' => $table,
1488-
'column' => $column,
1489-
'key' => $primary_key,
1490-
'value' => $result->$primary_key,
1487+
'table' => $table,
1488+
'column' => $column,
14911489
// Remove the colors for the format output.
1492-
'match' => str_replace( [ $colors['match'][0], $colors['match'][1] ], [ '', '' ], $col_val ),
1490+
'match' => str_replace(
1491+
[ $colors['match'][0], $colors['match'][1] ],
1492+
['',''],
1493+
$col_val
1494+
),
1495+
'primary_key_name' => $primary_key,
1496+
'primary_key_value' => $result->$primary_key,
14931497
];
14941498
} else {
14951499
WP_CLI::log( $matches_only ? $col_val : ( $one_line ? "{$table_column_val}:{$pk_val}{$col_val}" : "{$pk_val}{$col_val}" ) );
@@ -1504,7 +1508,7 @@ public function search( $args, $assoc_args ) {
15041508
$formatter_args = [
15051509
'format' => $format,
15061510
];
1507-
$formatter_fields = [ 'table', 'column', 'key', 'value', 'match' ];
1511+
$formatter_fields = [ 'table', 'column', 'match', 'primary_key_name', 'primary_key_value' ];
15081512

15091513
if ( $fields ) {
15101514
$fields = explode( ',', $assoc_args['fields'] );
@@ -1515,7 +1519,7 @@ public function search( $args, $assoc_args ) {
15151519
if ( count( $tables ) > 1 ) {
15161520
WP_CLI::error( 'The "ids" format can only be used for a single table.' );
15171521
}
1518-
$search_results = array_column( $search_results, 'value' );
1522+
$search_results = array_column( $search_results, 'primary_key_value' );
15191523
}
15201524

15211525
$formatter = new Formatter( $formatter_args, $formatter_fields );

0 commit comments

Comments
 (0)