public Schema::queryFieldInformation($table, $field)
Fetch the list of CHECK constraints used on a field.
We introspect the database to collect the information required by field alteration.
Parameters
$table: The non-prefixed name of the table.
$field: The name of the field.
Return value
An array of all the checks for the field.
File
- core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php, line 183
Class
- Schema
- PostgreSQL implementation of \Drupal\Core\Database\Schema.
Namespace
Drupal\Core\Database\Driver\pgsql
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | public function queryFieldInformation( $table , $field ) { $prefixInfo = $this ->getPrefixInfo( $table , TRUE); // Split the key into schema and table for querying. $schema = $prefixInfo [ 'schema' ]; $table_name = $prefixInfo [ 'table' ]; $this ->connection->addSavepoint(); try { $checks = $this ->connection->query( "SELECT conname FROM pg_class cl INNER JOIN pg_constraint co ON co.conrelid = cl.oid INNER JOIN pg_attribute attr ON attr.attrelid = cl.oid AND attr.attnum = ANY (co.conkey) INNER JOIN pg_namespace ns ON cl.relnamespace = ns.oid WHERE co.contype = 'c' AND ns.nspname = :schema AND cl.relname = :table AND attr.attname = :column" , array ( ':schema' => $schema , ':table' => $table_name , ':column' => $field , )); } catch (\Exception $e ) { $this ->connection->rollbackSavepoint(); throw $e ; } $this ->connection->releaseSavepoint(); $field_information = $checks ->fetchCol(); return $field_information ; } |
Please login to continue.