-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserTable.php
More file actions
46 lines (43 loc) · 1.36 KB
/
UserTable.php
File metadata and controls
46 lines (43 loc) · 1.36 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
<?php
use WebFiori\Database\ColOption;
use WebFiori\Database\DataType;
use WebFiori\Database\MySql\MySQLTable;
/**
* A custom table class that extends MySQLTable
*/
class UserTable extends MySQLTable {
public function __construct() {
parent::__construct('users_extended');
// Add columns using the fluent interface
$this->addColumns([
'id' => [
ColOption::TYPE => DataType::INT,
ColOption::SIZE => 11,
ColOption::PRIMARY => true,
ColOption::AUTO_INCREMENT => true
],
'username' => [
ColOption::TYPE => DataType::VARCHAR,
ColOption::SIZE => 50,
ColOption::NULL => false
],
'email' => [
ColOption::TYPE => DataType::VARCHAR,
ColOption::SIZE => 150,
ColOption::NULL => false
],
'full-name' => [
ColOption::TYPE => DataType::VARCHAR,
ColOption::SIZE => 100
],
'is-active' => [
ColOption::TYPE => DataType::BOOL,
ColOption::DEFAULT => true
],
'created-at' => [
ColOption::TYPE => DataType::TIMESTAMP,
ColOption::DEFAULT => 'current_timestamp'
]
]);
}
}