diff --git a/README.md b/README.md index a0a88377..6a29b280 100644 --- a/README.md +++ b/README.md @@ -342,6 +342,10 @@ wp db query [] [--dbuser=] [--dbpass=] [--=] [- Executes an arbitrary SQL query using `DB_HOST`, `DB_NAME`, `DB_USER` and `DB_PASSWORD` database credentials specified in wp-config.php. +Use the `--skip-column-names` MySQL argument to exclude the headers +from a SELECT query. Pipe the output to remove the ASCII table +entirely. + **OPTIONS** [] @@ -364,6 +368,12 @@ Executes an arbitrary SQL query using `DB_HOST`, `DB_NAME`, `DB_USER` # Execute a query stored in a file $ wp db query < debug.sql + # Query for a specific value in the database (pipe the result to remove the ASCII table borders) + $ wp db query 'SELECT option_value FROM wp_options WHERE option_name="home"' --skip-column-names + +---------------------+ + | https://example.com | + +---------------------+ + # Check all tables in the database $ wp db query "CHECK TABLE $(wp db tables | paste -s -d, -);" +---------------------------------------+-------+----------+----------+ diff --git a/src/DB_Command.php b/src/DB_Command.php index 484d259c..90215af0 100644 --- a/src/DB_Command.php +++ b/src/DB_Command.php @@ -401,6 +401,10 @@ public function cli( $_, $assoc_args ) { * Executes an arbitrary SQL query using `DB_HOST`, `DB_NAME`, `DB_USER` * and `DB_PASSWORD` database credentials specified in wp-config.php. * + * Use the `--skip-column-names` MySQL argument to exclude the headers + * from a SELECT query. Pipe the output to remove the ASCII table + * entirely. + * * ## OPTIONS * * [] @@ -423,6 +427,12 @@ public function cli( $_, $assoc_args ) { * # Execute a query stored in a file * $ wp db query < debug.sql * + * # Query for a specific value in the database (pipe the result to remove the ASCII table borders) + * $ wp db query 'SELECT option_value FROM wp_options WHERE option_name="home"' --skip-column-names + * +---------------------+ + * | https://example.com | + * +---------------------+ + * * # Check all tables in the database * $ wp db query "CHECK TABLE $(wp db tables | paste -s -d, -);" * +---------------------------------------+-------+----------+----------+