class IntColumnHandlerSQLite in Dynamic Entity Reference 8.2
SQLite implementation of denormalizing into integer columns.
Hierarchy
- class \Drupal\dynamic_entity_reference\Storage\IntColumnHandler implements IntColumnHandlerInterface
- class \Drupal\dynamic_entity_reference\Storage\IntColumnHandlerSQLite
Expanded class hierarchy of IntColumnHandlerSQLite
1 string reference to 'IntColumnHandlerSQLite'
1 service uses IntColumnHandlerSQLite
File
- src/
Storage/ IntColumnHandlerSQLite.php, line 8
Namespace
Drupal\dynamic_entity_reference\StorageView source
class IntColumnHandlerSQLite extends IntColumnHandler {
/**
* {@inheritdoc}
*/
protected function createBody($column_int, $column) {
return "{$column_int} = CAST({$column} AS INTEGER)";
}
/**
* {@inheritdoc}
*/
protected function createTrigger($trigger, $op, $prefixed_name, $body) {
$parts = explode('.', $prefixed_name);
// Simpletest for example prefixes with a database name but SQLite does
// not support referencing databases in the body of the trigger (even if it
// is the same database the triggering table is in).
$table_name = array_pop($parts);
$query = "\n CREATE TRIGGER {$trigger} AFTER {$op} ON {$prefixed_name}\n FOR EACH ROW\n BEGIN\n UPDATE {$table_name} SET {$body} WHERE ROWID=NEW.ROWID";
// SQLite requires a ; in the query which requires bypassing Drupal's built
// in single statement only protection. Although this method is not
// supposed to be called by user submitted data.
if (strpos($query, ';') !== FALSE) {
throw new \InvalidArgumentException('; is not supported in SQL strings. Use only one statement at a time.');
}
$this->connection
->query("{$query}; END", [], [
'allow_delimiter_in_query' => TRUE,
]);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
IntColumnHandler:: |
protected | property | The database connection. | |
IntColumnHandler:: |
public static | function | Checks whether all columns exist. | |
IntColumnHandler:: |
public | function |
Creates the _int columns and the triggers for them. Overrides IntColumnHandlerInterface:: |
|
IntColumnHandler:: |
public | function | Removes the trigger. | |
IntColumnHandler:: |
public | function | IntColumnHandler constructor. | |
IntColumnHandlerSQLite:: |
protected | function |
Creates the body of the trigger. Overrides IntColumnHandler:: |
|
IntColumnHandlerSQLite:: |
protected | function |
Actually creates the trigger. Overrides IntColumnHandler:: |