원클릭으로
drupal-queries
Drupal database queries — Select, Insert, Update, Delete using the database abstraction layer. Never concatenate SQL.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Drupal database queries — Select, Insert, Update, Delete using the database abstraction layer. Never concatenate SQL.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
HTMX in Drupal 11.3+ core — the Htmx PHP fluent builder, dynamic forms with swapOob, partial routes with _htmx_route, response headers, and Drupal.behaviors integration. Use when building interactive UI without full-page reloads using Drupal's native HTMX support.
DDEV local development expertise. Use when working with DDEV projects, containers, configuration, or troubleshooting DDEV environments.
Custom Docker Compose local development patterns. Use when working with Docker-based local environments, container configuration, or troubleshooting Docker setups.
Drupal access control — permissions.yml, access callbacks, AccessResult, custom access checkers, and entity access.
Drupal Cache API — cache tags, contexts, max-age, cache bins, invalidation, and adding cache metadata to render arrays.
Drupal Composer management — requiring modules, updates, patches via composer-patches, and version constraints.
| name | drupal-queries |
| description | Drupal database queries — Select, Insert, Update, Delete using the database abstraction layer. Never concatenate SQL. |
// WRONG — SQL injection risk
$result = $this->database->query("SELECT * FROM {node} WHERE type = '$type'");
// CORRECT — parameterized query
$result = $this->database->query(
"SELECT nid, title FROM {node} WHERE type = :type",
[':type' => $type]
);
$query = $this->database->select('node_field_data', 'n');
$query->fields('n', ['nid', 'title', 'status']);
$query->condition('n.type', 'article');
$query->condition('n.status', 1);
$query->orderBy('n.created', 'DESC');
$query->range(0, 10);
$results = $query->execute()->fetchAll();
// Fetch as associative array
$results = $query->execute()->fetchAllAssoc('nid');
// Fetch single value
$count = $query->countQuery()->execute()->fetchField();
$query = $this->database->select('node_field_data', 'n');
$query->join('node__field_tags', 'tags', 'n.nid = tags.entity_id');
$query->fields('n', ['nid', 'title']);
$query->condition('tags.field_tags_target_id', $tid);
$query->condition('n.status', 1);
$this->database->insert('my_table')
->fields([
'uid' => $uid,
'data' => serialize($data),
'created' => \Drupal::time()->getRequestTime(),
])
->execute();
$this->database->upsert('my_table')
->key('uid')
->fields(['uid', 'data', 'updated'])
->values([
'uid' => $uid,
'data' => serialize($data),
'updated' => \Drupal::time()->getRequestTime(),
])
->execute();
$this->database->update('my_table')
->fields(['data' => serialize($data)])
->condition('uid', $uid)
->execute();
$this->database->delete('my_table')
->condition('uid', $uid)
->execute();
// Always prefer EntityQuery over raw SQL for entities
$query = $this->entityTypeManager->getStorage('node')->getQuery()
->accessCheck(TRUE)
->condition('type', 'article')
->condition('status', 1)
->sort('created', 'DESC')
->range(0, 10);
$nids = $query->execute();
use Drupal\Core\Database\Connection;
public function __construct(
private readonly Connection $database,
) {}
Service ID: database
$transaction = $this->database->startTransaction();
try {
$this->database->insert('my_table')->fields([...])->execute();
$this->database->update('other_table')->fields([...])->execute();
}
catch (\Exception $e) {
$transaction->rollBack();
throw $e;
}
// Transaction commits when $transaction goes out of scope