You are here

class IntColumnHandlerMySQL in Dynamic Entity Reference 8.2

MySQL implementation of denormalizing into integer columns.

Hierarchy

Expanded class hierarchy of IntColumnHandlerMySQL

1 string reference to 'IntColumnHandlerMySQL'
dynamic_entity_reference.services.yml in ./dynamic_entity_reference.services.yml
dynamic_entity_reference.services.yml
1 service uses IntColumnHandlerMySQL
mysql.dynamic_entity_reference.storage.create_column in ./dynamic_entity_reference.services.yml
Drupal\dynamic_entity_reference\Storage\IntColumnHandlerMySQL

File

src/Storage/IntColumnHandlerMySQL.php, line 8

Namespace

Drupal\dynamic_entity_reference\Storage
View source
class IntColumnHandlerMySQL extends IntColumnHandler {

  /**
   * {@inheritdoc}
   */
  protected function createBody($column_int, $column) {
    return "NEW.{$column_int} = IF(NEW.{$column} REGEXP '^[0-9]+\$', CAST(NEW.{$column} AS UNSIGNED), NULL)";
  }

  /**
   * {@inheritdoc}
   */
  protected function createTrigger($trigger, $op, $prefixed_name, $body) {
    $this->connection
      ->query("CREATE TRIGGER {$trigger} BEFORE {$op} ON {$prefixed_name} FOR EACH ROW SET {$body}", [], [
      'allow_square_brackets' => TRUE,
    ]);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
IntColumnHandler::$connection protected property The database connection.
IntColumnHandler::allColumnsExist public static function Checks whether all columns exist.
IntColumnHandler::create public function Creates the _int columns and the triggers for them. Overrides IntColumnHandlerInterface::create
IntColumnHandler::delete public function Removes the trigger.
IntColumnHandler::__construct public function IntColumnHandler constructor.
IntColumnHandlerMySQL::createBody protected function Creates the body of the trigger. Overrides IntColumnHandler::createBody
IntColumnHandlerMySQL::createTrigger protected function Actually creates the trigger. Overrides IntColumnHandler::createTrigger