You are here

public function WebformSubmissionStorage::hasSubmissionValue in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/WebformSubmissionStorage.php \Drupal\webform\WebformSubmissionStorage::hasSubmissionValue()

Determine if a webform element has submission values.

Parameters

\Drupal\webform\WebformInterface $webform: A webform.

string $element_key: An element key.

Return value

bool TRUE if a webform element has submission values.

Overrides WebformSubmissionStorageInterface::hasSubmissionValue

File

src/WebformSubmissionStorage.php, line 307

Class

WebformSubmissionStorage
Defines the webform submission storage.

Namespace

Drupal\webform

Code

public function hasSubmissionValue(WebformInterface $webform, $element_key) {

  /** @var \Drupal\Core\Database\StatementInterface $result */
  $result = $this->database
    ->select('webform_submission_data', 'sd')
    ->fields('sd', [
    'sid',
  ])
    ->condition('sd.webform_id', $webform
    ->id())
    ->condition('sd.name', $element_key)
    ->range(0, 1)
    ->execute();
  return $result
    ->fetchAssoc() ? TRUE : FALSE;
}