I am creating a Drupal Dashboard (PHP 7.2, Drupal 8.9). I'm trying to query the node table using the following code.
$database = \Drupal::database();
$query = $database->query("SELECT field_advertiser_id_value FROM {node__field_advertiser_id} WHERE entity_id = :entity_id", [
':entity_id' => $entity_id
]);
$result = $query->execute();
print_r($result);
I am not sure why $query->execute()
returns false
. This table exists in the l database.
The database contains both the node and the node__field_advertiser_id tables.
Inserting data in the node__field_advertiser_id works correctly.
$database = \Drupal::database();
$database->insert('node__field_advertiser_id')
->fields([
'entity_id' => $advertiser_nid,
'revision_id' => 1,
'delta' => 0,
'field_advertiser_id_value' => $advertiser_id
])
->execute();
I am trying to fetch details from the node__field_advertiser_id from hook_node_delete()
. The data is still there in the table when I try to run the SQL query.
It would be great if anyone can help me out with this.