UserModel.php
1.93 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
/**
*
* @author Adhidarma <adhisimon@gmail.com>
*/
class UserModel extends Model {
protected $table_name = 'users';
protected $table_fields = array(
'email' => array(
'type' => \DB\SQL\Schema::DT_VARCHAR128,
'nullable' => false,
'index' => true,
'unique' => true,
),
'fullname' => array(
'type' => \DB\SQL\Schema::DT_VARCHAR128,
'nullable' => true,
'index' => false,
'unique' => false,
),
'phone' => array(
'type' => \DB\SQL\Schema::DT_VARCHAR128,
'nullable' => true,
'index' => false,
'unique' => false,
),
'password' => array(
'type' => \DB\SQL\Schema::DT_VARCHAR512,
'nullable' => true,
'index' => false,
'unique' => false,
),
'enable' => array(
'type' => \DB\SQL\Schema::DT_BOOLEAN,
'nullable' => true,
'index' => false,
'unique' => false,
'default' => 1,
),
'created' => array(
'type' => \DB\SQL\Schema::DT_DATETIME,
'nullable' => false,
'index' => false,
'unique' => false,
),
'modified' => array(
'type' => \DB\SQL\Schema::DT_TIMESTAMP,
'nullable' => true,
'index' => false,
'unique' => false,
'default' => \DB\SQL\Schema::DF_CURRENT_TIMESTAMP,
),
);
protected $initial_rows = array(
array(
'email' => 'admin@example.com',
'fullname' => 'Administrator',
'password' => '$1$xl5Amydz$YZVaSpUFkOlVGaoNUAtBa.', // crypt('admin')
'enable' => 1,
'created' => self::DB_FUNCTION_NOW
),
);
public function getByEmail($email) {
return $this->getItemByFieldValue('email', $email);
}
}