blob: bf9e75b4597a68a11aa23062620cf17c08a30570 [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);
51
52 if (strpos(DB_DRIVER, 'sqlite') === FALSE)
53 {
54 $db->insert_batch($table, $dummy_data);
55 }
56 else
57 {
58 foreach ($dummy_data as $single_dummy_data)
59 {
60 $db->insert($table, $single_dummy_data);
61 }
62 }
63 }
64 }
65}