Wp db query (WP-CLI): verschil tussen versies
Naar navigatie springen
Naar zoeken springen
Regel 70: | Regel 70: | ||
I seem to get weird results with an SQL string like this: <code>update wp_term_taxonomy set description=replace(description, 'één-na-kortste', 'zweitkürzeste');</code> | I seem to get weird results with an SQL string like this: <code>update wp_term_taxonomy set description=replace(description, 'één-na-kortste', 'zweitkürzeste');</code> | ||
+ | |||
+ | == Casus: Retrieve all term-id of a taxonomy (2022.10) == |
Versie van 24 okt 2022 12:08
wp db query: Execute an SQL query against a WordPress database:
$ wp help db query NAME wp db query DESCRIPTION Executes a SQL query against the database. SYNOPSIS wp db query [<sql>] [--dbuser=<value>] [--dbpass=<value>] [--<field>=<value>] [--defaults] Executes an arbitrary SQL query using `DB_HOST`, `DB_NAME`, `DB_USER` and `DB_PASSWORD` database credentials specified in wp-config.php. OPTIONS [<sql>] A SQL query. If not passed, will try to read from STDIN. [--dbuser=<value>] Username to pass to mysql. Defaults to DB_USER. [--dbpass=<value>] Password to pass to mysql. Defaults to DB_PASSWORD. [--<field>=<value>] Extra arguments to pass to mysql. [Refer to mysql docs](https://dev.mysql.com/doc/en/mysql-command-options.html). [--defaults] Loads the environment's MySQL option files. Default behavior is to skip loading them to avoid failures due to misconfiguration. EXAMPLES # Execute a query stored in a file $ wp db query < debug.sql # Check all tables in the database $ wp db query "CHECK TABLE $(wp db tables | paste -s -d, -);" +---------------------------------------+-------+----------+----------+ | Table | Op | Msg_type | Msg_text | +---------------------------------------+-------+----------+----------+ | wordpress_dbase.wp_users | check | status | OK | | wordpress_dbase.wp_usermeta | check | status | OK | | wordpress_dbase.wp_posts | check | status | OK | | wordpress_dbase.wp_comments | check | status | OK | | wordpress_dbase.wp_links | check | status | OK | | wordpress_dbase.wp_options | check | status | OK | | wordpress_dbase.wp_postmeta | check | status | OK | | wordpress_dbase.wp_terms | check | status | OK | | wordpress_dbase.wp_term_taxonomy | check | status | OK | | wordpress_dbase.wp_term_relationships | check | status | OK | | wordpress_dbase.wp_termmeta | check | status | OK | | wordpress_dbase.wp_commentmeta | check | status | OK | +---------------------------------------+-------+----------+----------+ # Pass extra arguments through to MySQL $ wp db query 'SELECT * FROM wp_options WHERE option_name="home"' --skip-column-names +---+------+------------------------------+-----+ | 2 | home | http://wordpress-develop.dev | yes | +---+------+------------------------------+-----+
Casus: Problem with non-ASCII characters? (2022.08)
I seem to get weird results with an SQL string like this: update wp_term_taxonomy set description=replace(description, 'één-na-kortste', 'zweitkürzeste');