Skip to content

Commit 1c9b2e8

Browse files
committed
Use value instead of ID for the primary key column
1 parent fd762a7 commit 1c9b2e8

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/DB_Command.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,14 +1301,14 @@ public function prefix() {
13011301
*
13021302
* # Search for a string and print the result as a table
13031303
* $ wp db search https://localhost:8889 --format=table
1304-
* +------------+--------------+-----------+----+-----------------------------+
1305-
* | table | column | key | ID | match |
1306-
* +------------+--------------+-----------+----+-----------------------------+
1307-
* | wp_options | option_value | option_id | 1 | https://localhost:8889 |
1308-
* | wp_options | option_value | option_id | 2 | https://localhost:8889 |
1309-
* | wp_posts | guid | ID | 1 | https://localhost:8889/?p=1 |
1310-
* | wp_users | user_url | ID | 1 | https://localhost:8889 |
1311-
* +------------+--------------+-----------+----+-----------------------------+
1304+
* +------------+--------------+-----------+-------+-----------------------------+
1305+
* | table | column | key | value | match |
1306+
* +------------+--------------+-----------+-------+-----------------------------+
1307+
* | wp_options | option_value | option_id | 1 | https://localhost:8889 |
1308+
* | wp_options | option_value | option_id | 2 | https://localhost:8889 |
1309+
* | wp_posts | guid | ID | 1 | https://localhost:8889/?p=1 |
1310+
* | wp_users | user_url | ID | 1 | https://localhost:8889 |
1311+
* +------------+--------------+-----------+-------+-----------------------------+
13121312
*
13131313
* # Search for a string and get only the IDs (only works for a single table)
13141314
* $ wp db search https://localhost:8889 wp_options --format=ids
@@ -1487,7 +1487,7 @@ public function search( $args, $assoc_args ) {
14871487
'table' => $table,
14881488
'column' => $column,
14891489
'key' => $primary_key,
1490-
'ID' => $result->$primary_key,
1490+
'value' => $result->$primary_key,
14911491
// Remove the colors for the format output.
14921492
'match' => str_replace( [ $colors['match'][0], $colors['match'][1] ], [ '', '' ], $col_val ),
14931493
];
@@ -1504,7 +1504,7 @@ public function search( $args, $assoc_args ) {
15041504
$formatter_args = [
15051505
'format' => $format,
15061506
];
1507-
$formatter_fields = [ 'table', 'column', 'key', 'ID', 'match' ];
1507+
$formatter_fields = [ 'table', 'column', 'key', 'value', 'match' ];
15081508

15091509
if ( $fields ) {
15101510
$fields = explode( ',', $assoc_args['fields'] );
@@ -1515,7 +1515,7 @@ public function search( $args, $assoc_args ) {
15151515
if ( count( $tables ) > 1 ) {
15161516
WP_CLI::error( 'The "ids" format can only be used for a single table.' );
15171517
}
1518-
$search_results = array_column( $search_results, 'ID' );
1518+
$search_results = array_column( $search_results, 'value' );
15191519
}
15201520

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

0 commit comments

Comments
 (0)