function dbtng_example_install

Same name in other branches
  1. 3.x modules/dbtng_example/dbtng_example.install \dbtng_example_install()
  2. 7.x-1.x dbtng_example/dbtng_example.install \dbtng_example_install()

Implements hook_install().

Creates some default entries on this module custom table.

See also

hook_install()

Related topics

File

modules/dbtng_example/dbtng_example.install, line 17

Code

function dbtng_example_install() {
    // Insert some example data into our schema.
    $entries = [
        [
            'name' => 'John',
            'surname' => 'Doe',
            'age' => 0,
        ],
        [
            'name' => 'John',
            'surname' => 'Roe',
            'age' => 100,
            'uid' => 1,
        ],
    ];
    $connection = \Drupal::database();
    foreach ($entries as $entry) {
        $connection->insert('dbtng_example')
            ->fields($entry)
            ->execute();
    }
}