1 <?php
2 /**
3 * Cross - a micro PHP 5 framework
4 *
5 * @link http://www.crossphp.com
6 * @license MIT License
7 */
8 namespace Cross\I;
9
10 /**
11 * Interface SqlInterface
12 *
13 * @package Cross\I
14 */
15 interface SqlInterface
16 {
17 /**
18 * 获取一条数据
19 *
20 * @param string $table 表名
21 * @param string $fields 字段
22 * @param string|array $where 条件(建议只使用字符串常量,包含变量时请使用数组)
23 * @return mixed
24 */
25 function get($table, $fields, $where);
26
27 /**
28 * 批量获取表中的数据
29 *
30 * @param string $table 表名
31 * @param string $fields 要获取的字段名
32 * @param string|array $where 条件(建议只使用字符串常量,包含变量时请使用数组)
33 * @param int|string $order 排序
34 * @param int|string $group_by 分组
35 * @param int|string $limit 0表示无限制
36 * @return mixed
37 */
38 function getAll($table, $fields, $where = '', $order = 1, $group_by = 1, $limit = 0);
39
40 /**
41 * 带分页的查询
42 *
43 * @param string $table 表名
44 * @param string $fields 字段名
45 * @param string|array $where 条件(建议只使用字符串常量,包含变量时请使用数组)
46 * @param string|int $order 排序
47 * @param array $page array('p', 'limit'); p表示当前页数, limit表示要取出的条数
48 * @param int $group_by
49 * @return mixed
50 */
51 function find($table, $fields, $where, $order = 1, array &$page = array('p', 'limit'), $group_by = 1);
52
53 /**
54 * 添加数据
55 *
56 * @param string $table 表名
57 * @param string $data 要插入的数据
58 * @param bool $multi 是否批量插入
59 * @return mixed
60 */
61 function add($table, $data, $multi = false);
62
63 /**
64 * 更新数据
65 *
66 * @param string $table 表名
67 * @param string $data 要更新的数据
68 * @param string $where 筛选条件
69 * @return mixed
70 */
71 function update($table, $data, $where);
72
73 /**
74 * 删除数据
75 *
76 * @param string $table 表名
77 * @param string $where 条件
78 * @return mixed
79 */
80 function del($table, $where);
81
82 }
83