1 | <?php |
||
10 | abstract class Model |
||
11 | { |
||
12 | /** |
||
13 | * @var Database |
||
14 | */ |
||
15 | public static $db; |
||
16 | |||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | protected $primaryKey = "id"; |
||
21 | |||
22 | /** |
||
23 | * @var null |
||
24 | */ |
||
25 | protected static $table = null; |
||
26 | |||
27 | /** |
||
28 | * @var array |
||
29 | */ |
||
30 | protected $data = array(); |
||
31 | |||
32 | /** |
||
33 | * @var bool |
||
34 | */ |
||
35 | protected $isNewRow = true; |
||
36 | |||
37 | /** |
||
38 | * @param array $data |
||
39 | * @param bool $isNewRow |
||
40 | */ |
||
41 | public function __construct($data = array(), $isNewRow = true) |
||
46 | |||
47 | /** |
||
48 | * @param array $data |
||
49 | * @return static |
||
50 | */ |
||
51 | public static function create($data = array()) |
||
55 | |||
56 | /** |
||
57 | * @param null $columns |
||
58 | * @return Database |
||
59 | */ |
||
60 | public static function select($columns = null) |
||
65 | |||
66 | /** |
||
67 | * @param $name |
||
68 | * @return array |
||
69 | */ |
||
70 | public function __get($name) |
||
74 | |||
75 | /** |
||
76 | * @param $name |
||
77 | * @param $value |
||
78 | */ |
||
79 | public function __set($name, $value) |
||
83 | |||
84 | /** |
||
85 | * @return bool |
||
86 | * @throws \Exception |
||
87 | */ |
||
88 | public function delete() |
||
97 | |||
98 | /** |
||
99 | * @return bool|mixed |
||
100 | * @throws \Exception |
||
101 | */ |
||
102 | public function save() |
||
125 | } |
||
126 |