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