@@ -58,6 +58,10 @@ |
||
58 | 58 | public function update($data){ |
59 | 59 | return $this->db->update($this->table,$data); |
60 | 60 | } |
61 | + |
|
62 | + /** |
|
63 | + * @param string $field |
|
64 | + */ |
|
61 | 65 | public function field($field){ |
62 | 66 | $this->field=$field; |
63 | 67 | return $this; |
@@ -17,57 +17,57 @@ |
||
17 | 17 | protected $limitCount=null; |
18 | 18 | public function __construct() |
19 | 19 | { |
20 | - if(!$this->dbConn){ |
|
20 | + if (!$this->dbConn) { |
|
21 | 21 | $this->dbConn='main'; |
22 | 22 | } |
23 | - $this->db = Mysql::getDb($this->dbConn); |
|
23 | + $this->db=Mysql::getDb($this->dbConn); |
|
24 | 24 | } |
25 | - public function __call($method,$arg){ |
|
25 | + public function __call($method, $arg) { |
|
26 | 26 | $ret=$this; |
27 | - if(method_exists ($this->db, $method)){ |
|
28 | - $ret=call_user_func_array(array($this->db,$method),$arg); |
|
27 | + if (method_exists($this->db, $method)) { |
|
28 | + $ret=call_user_func_array(array($this->db, $method), $arg); |
|
29 | 29 | } |
30 | - return $ret==$this->db? $this: $ret; |
|
30 | + return $ret == $this->db ? $this : $ret; |
|
31 | 31 | } |
32 | - public function __get($name){ |
|
33 | - if(property_exists($this->db, $name)){ |
|
32 | + public function __get($name) { |
|
33 | + if (property_exists($this->db, $name)) { |
|
34 | 34 | return $this->db->$name; |
35 | 35 | } |
36 | - throw new MemberAccessException('model Property ' . $name . ' not exists'); |
|
36 | + throw new MemberAccessException('model Property '.$name.' not exists'); |
|
37 | 37 | } |
38 | - public function limit($limit){ |
|
38 | + public function limit($limit) { |
|
39 | 39 | $this->limitCount=$limit; |
40 | 40 | return $this; |
41 | 41 | } |
42 | - public function find(){ |
|
43 | - return $this->db->getOne($this->table,$this->field); |
|
42 | + public function find() { |
|
43 | + return $this->db->getOne($this->table, $this->field); |
|
44 | 44 | } |
45 | - public function select(){ |
|
46 | - return $this->db->get($this->table,$this->limitCount?$this->limitCount:null,$this->field); |
|
45 | + public function select() { |
|
46 | + return $this->db->get($this->table, $this->limitCount ? $this->limitCount : null, $this->field); |
|
47 | 47 | } |
48 | - public function count(){ |
|
48 | + public function count() { |
|
49 | 49 | return $this->field("count(*) as count")->find()['count']; |
50 | 50 | } |
51 | - public function table($table){ |
|
51 | + public function table($table) { |
|
52 | 52 | $this->table=$table; |
53 | 53 | return $this; |
54 | 54 | } |
55 | - public function add($data){ |
|
56 | - return $this->db->insert($this->table,$data); |
|
55 | + public function add($data) { |
|
56 | + return $this->db->insert($this->table, $data); |
|
57 | 57 | } |
58 | - public function update($data){ |
|
59 | - return $this->db->update($this->table,$data); |
|
58 | + public function update($data) { |
|
59 | + return $this->db->update($this->table, $data); |
|
60 | 60 | } |
61 | - public function field($field){ |
|
61 | + public function field($field) { |
|
62 | 62 | $this->field=$field; |
63 | 63 | return $this; |
64 | 64 | } |
65 | - public function delete(){ |
|
65 | + public function delete() { |
|
66 | 66 | return $this->db->delete($this->table); |
67 | 67 | } |
68 | - public function page($page,$pageLimit='10'){ |
|
68 | + public function page($page, $pageLimit='10') { |
|
69 | 69 | $this->db->pageLimit=$pageLimit; |
70 | - $info= $this->db->paginate($this->table,$page); |
|
70 | + $info=$this->db->paginate($this->table, $page); |
|
71 | 71 | return $info; |
72 | 72 | } |
73 | 73 | } |
74 | 74 | \ No newline at end of file |
@@ -2,13 +2,13 @@ |
||
2 | 2 | @ini_set('date.timezone', 'Asia/Shanghai'); |
3 | 3 | @header('content-type:text/html;charset=utf-8'); |
4 | 4 | |
5 | -define('EXPORT_PATH',__DIR__); |
|
6 | -define('PUCK_VER','1.0.17'); |
|
7 | -if(DEBUG){ |
|
5 | +define('EXPORT_PATH', __DIR__); |
|
6 | +define('PUCK_VER', '1.0.17'); |
|
7 | +if (DEBUG) { |
|
8 | 8 | error_reporting(E_ALL); |
9 | 9 | @ini_set('display_errors', 'On'); |
10 | 10 | @ob_start(); |
11 | - $whoops = new \Whoops\Run; |
|
11 | + $whoops=new \Whoops\Run; |
|
12 | 12 | $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler); |
13 | 13 | $whoops->register(); |
14 | 14 | } |
15 | 15 | \ No newline at end of file |