1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
<?php
class Mock_Database_Schema_Skeleton {
/**
* Create the dummy tables
*
* @return void
*/
public static function create_tables($forge)
{
// Job Table
$forge->add_field(array(
'id' => array(
'type' => 'INT',
'constraint' => 3,
),
'name' => array(
'type' => 'VARCHAR',
'constraint' => 40,
),
'description' => array(
'type' => 'TEXT',
'constraint' => 0,
),
));
$forge->add_key('id', TRUE);
$forge->create_table('job', TRUE);
}
/**
* Create the dummy datas
*
* @return void
*/
public static function create_data($db)
{
// Job Data
$data = array(
'job' => array(
array('id' => 1, 'name' => 'Developer', 'description' => 'Awesome job, but sometimes makes you bored'),
array('id' => 2, 'name' => 'Politician', 'description' => 'This is not really a job'),
array('id' => 3, 'name' => 'Accountant', 'description' => 'Boring job, but you will get free snack at lunch'),
array('id' => 4, 'name' => 'Musician', 'description' => 'Only Coldplay can actually called Musician'),
),
);
foreach ($data as $table => $dummy_data)
{
$db->truncate($table);
foreach ($dummy_data as $single_dummy_data)
{
$db->insert($table, $single_dummy_data);
}
}
}
}
|