1 database_example.install database_example_install()

Implements hook_install().

We will create a default entry in the database.

See also

hook_install()

Related topics

File

modules/examples/database_example/database_example.install, line 16
Install, update, and uninstall functions for the Database Example module.

Code

function database_example_install() {
  // Add a default entry.
  $fields = array(
    'name' => 'John',
    'surname' => 'Doe',
    'age' => 0,
  );
  db_insert('database_example')
    ->fields($fields)
    ->execute();

  // Add another entry.
  $fields = array(
    'name' => 'John',
    'surname' => 'Roe',
    'age' => 100,
    'uid' => 1,
  );
  db_insert('database_example')
    ->fields($fields)
    ->execute();
}