function SqlContentEntityStorageSchema::hasNullFieldPropertyData

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::hasNullFieldPropertyData()
  2. 10 core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::hasNullFieldPropertyData()
  3. 11.x core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::hasNullFieldPropertyData()

Checks whether a field property has NULL values.

Parameters

string $table_name: The name of the table to inspect.

string $column_name: The name of the column holding the field property data.

Return value

bool TRUE if NULL data is found, FALSE otherwise.

1 call to SqlContentEntityStorageSchema::hasNullFieldPropertyData()
SqlContentEntityStorageSchema::updateSharedTableSchema in core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php
Updates the schema for a field stored in a shared table.

File

core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php, line 2023

Class

SqlContentEntityStorageSchema
Defines a schema handler that supports revisionable, translatable entities.

Namespace

Drupal\Core\Entity\Sql

Code

protected function hasNullFieldPropertyData($table_name, $column_name) {
    $query = $this->database
        ->select($table_name, 't')
        ->fields('t', [
        $column_name,
    ])
        ->range(0, 1);
    $query->isNull('t.' . $column_name);
    $result = $query->execute()
        ->fetchAssoc();
    return (bool) $result;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.