function tablesort_example_install in Examples for Developers 7
Same name and namespace in other branches
- 8 tablesort_example/tablesort_example.install \tablesort_example_install()
- 3.x modules/tablesort_example/tablesort_example.install \tablesort_example_install()
Implements hook_install().
Related topics
File
- tablesort_example/
tablesort_example.install, line 16 - Install and uninstall functions for the tablesort example module.
Code
function tablesort_example_install() {
// Let's fill the database with some values for sorting.
$rows = array(
array(
'numbers' => 1,
'alpha' => 'e',
'random' => '912cv21',
),
array(
'numbers' => 2,
'alpha' => 'a',
'random' => '0kuykuh',
),
array(
'numbers' => 3,
'alpha' => 'm',
'random' => 'fuye8734h',
),
array(
'numbers' => 4,
'alpha' => 'w',
'random' => '80jsv772',
),
array(
'numbers' => 5,
'alpha' => 'o',
'random' => 'd82sf-csj',
),
array(
'numbers' => 6,
'alpha' => 's',
'random' => 'au832',
),
array(
'numbers' => 7,
'alpha' => 'e',
'random' => 't982hkv',
),
);
if (db_table_exists('tablesort_example')) {
foreach ($rows as $row) {
db_insert('tablesort_example')
->fields($row)
->execute();
}
}
}