📜  drush run sql select - SQL (1)

📅  最后修改于: 2023-12-03 15:30:34.520000             🧑  作者: Mango

使用 drush run sql select 查询主题

drush run sql select 命令可以用于在 Drupal 站点上查询数据库表。下面是一个示例命令,用于查询数据库中的所有主题:

drush run sql select "name, description FROM system WHERE type = 'theme'" --format=markdown

上述命令会查询 system 表中的所有主题,并返回每个主题的名称和描述。返回的结果将被格式化为 markdown,方便阅读和使用。

示例输出:

| name            | description                                              |
| --------------- | -------------------------------------------------------- |
| bartik          | The default theme for Drupal 8.                          |
| classy          | A theme that relies on inheritance to reduce duplication. |
| stable          | A basic, minimally styled theme that provides a rock-solid foundation. |
| seven           | The default admin theme for Drupal 8.                     |
| stark           | A very plain, minimalistic theme.                         |
| twig\_default   | A simple, clean, configurable theme.                      |
| yourtheme       | Custom theme for your own site.                           |

注意,在命令的末尾,我们使用了 --format=markdown 参数来指定输出格式为 markdown。如果没有指定输出格式,默认将返回普通文本。

最后,为了保证代码片段的可读性和易用性,请在返回的结果中按照 markdown 格式标明代码片段。如下所示:

Here is an example:

```json
{
  "field_name": "field_example",
  "show_label": false,
  "label_display": "hidden",
  "type": "text",
  "weight": 0
}

This code defines a field configuration that sets the field name to "field_example", hides the label, and sets the field type to "text".