blob: 6610d6b59c1e09fa77bd675d82bd580bb23b1a28 [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 */
Taufan Adityab0703b02012-04-05 02:31:52 +070010 public static function create_tables($forge, $driver)
Taufan Aditya5b421662012-04-05 01:24:50 +070011 {
12 // Job Table
13 $forge->add_field(array(
14 'id' => array(
Taufan Aditya1bfc0d92012-04-05 02:25:25 +070015 'type' => 'INTEGER',
Taufan Aditya5b421662012-04-05 01:24:50 +070016 'constraint' => 3,
17 ),
18 'name' => array(
19 'type' => 'VARCHAR',
20 'constraint' => 40,
21 ),
22 'description' => array(
23 'type' => 'TEXT',
Taufan Aditya5b421662012-04-05 01:24:50 +070024 ),
25 ));
26 $forge->add_key('id', TRUE);
Taufan Adityab0703b02012-04-05 02:31:52 +070027 $forge->create_table('job', (strpos($driver, 'pgsql') === FALSE));
Taufan Aditya5b421662012-04-05 01:24:50 +070028 }
29
30 /**
31 * Create the dummy datas
32 *
33 * @return void
34 */
35 public static function create_data($db)
36 {
37 // Job Data
38 $data = array(
39 'job' => array(
40 array('id' => 1, 'name' => 'Developer', 'description' => 'Awesome job, but sometimes makes you bored'),
41 array('id' => 2, 'name' => 'Politician', 'description' => 'This is not really a job'),
42 array('id' => 3, 'name' => 'Accountant', 'description' => 'Boring job, but you will get free snack at lunch'),
43 array('id' => 4, 'name' => 'Musician', 'description' => 'Only Coldplay can actually called Musician'),
44 ),
45 );
46
47 foreach ($data as $table => $dummy_data)
48 {
49 $db->truncate($table);
Taufan Aditya024098d2012-04-05 01:51:57 +070050
51 foreach ($dummy_data as $single_dummy_data)
Taufan Aditya5b421662012-04-05 01:24:50 +070052 {
Taufan Aditya024098d2012-04-05 01:51:57 +070053 $db->insert($table, $single_dummy_data);
Taufan Aditya5b421662012-04-05 01:24:50 +070054 }
55 }
56 }
57}