function Connection::hasJson

Same name in this branch
  1. 11.x core/modules/pgsql/src/Driver/Database/pgsql/Connection.php \Drupal\pgsql\Driver\Database\pgsql\Connection::hasJson()
Same name in other branches
  1. 9 core/modules/pgsql/src/Driver/Database/pgsql/Connection.php \Drupal\pgsql\Driver\Database\pgsql\Connection::hasJson()
  2. 9 core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::hasJson()
  3. 10 core/modules/pgsql/src/Driver/Database/pgsql/Connection.php \Drupal\pgsql\Driver\Database\pgsql\Connection::hasJson()
  4. 10 core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::hasJson()

Runs a simple query to validate json datatype support.

Return value

bool Returns the query result.

1 method overrides Connection::hasJson()
Connection::hasJson in core/modules/pgsql/src/Driver/Database/pgsql/Connection.php
Runs a simple query to validate json datatype support.

File

core/lib/Drupal/Core/Database/Connection.php, line 1456

Class

Connection
Base Database API class.

Namespace

Drupal\Core\Database

Code

public function hasJson() : bool {
    try {
        return (bool) $this->query('SELECT JSON_TYPE(\'1\')');
    } catch (\Exception) {
        return FALSE;
    }
}

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