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
| <?php
| /**
|
| CREATE TABLE `phalapi_curd` (
| `id` int(10) NOT NULL AUTO_INCREMENT,
| `title` varchar(20) DEFAULT NULL,
| `content` text,
| `state` tinyint(4) DEFAULT NULL,
| `post_date` datetime DEFAULT NULL,
| PRIMARY KEY (`id`)
| ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
|
| */
|
| class Model_Examples_CURD extends PhalApi_Model_NotORM {
|
| protected function getTableName($id) {
| return 'curd';
| }
|
| public function getListItems($state, $page, $perpage) {
| return $this->getORM()
| ->select('*')
| ->where('state', $state)
| ->order('post_date DESC')
| ->limit(($page - 1) * $perpage, $perpage)
| ->fetchAll();
| }
|
| public function getListTotal($state) {
| $total = $this->getORM()
| ->where('state', $state)
| ->count('id');
|
| return intval($total);
| }
| }
|
|