Completed
Push — master ( a80f1b...13c9a3 )
by kill
07:33
created
core/Model.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -15,60 +15,60 @@
 block discarded – undo
15 15
     protected $limitCount=null;
16 16
     public function __construct()
17 17
     {
18
-        if(!$this->dbConn){
18
+        if (!$this->dbConn) {
19 19
             $this->dbConn='main';
20 20
         }
21
-        $this->db = Mysql::getDb($this->dbConn);
21
+        $this->db=Mysql::getDb($this->dbConn);
22 22
     }
23
-    public function __call($method,$arg){
23
+    public function __call($method, $arg) {
24 24
         $ret=$this;
25
-        if(method_exists ($this->db, $method)){
26
-            $ret=call_user_func_array(array($this->db,$method),$arg);
25
+        if (method_exists($this->db, $method)) {
26
+            $ret=call_user_func_array(array($this->db, $method), $arg);
27 27
         }
28
-        return $ret==$this->db? $this: $ret;
28
+        return $ret == $this->db ? $this : $ret;
29 29
     }
30
-    public function __get($name){
31
-        if(property_exists($this->db, $name)){
30
+    public function __get($name) {
31
+        if (property_exists($this->db, $name)) {
32 32
             return $this->db->$name;
33 33
         }
34
-        throw new MemberAccessException('model Property ' . $name . ' not exists');
34
+        throw new MemberAccessException('model Property '.$name.' not exists');
35 35
     }
36
-    public function limit($limit){
36
+    public function limit($limit) {
37 37
         $this->limitCount=$limit;
38 38
         return $this;
39 39
     }
40
-    public function find(){
41
-        return $this->db->getOne($this->table,$this->field);
40
+    public function find() {
41
+        return $this->db->getOne($this->table, $this->field);
42 42
     }
43
-    public function select(){
44
-        return $this->db->get($this->table,$this->limitCount?$this->limitCount:null,$this->field);
43
+    public function select() {
44
+        return $this->db->get($this->table, $this->limitCount ? $this->limitCount : null, $this->field);
45 45
     }
46
-    public function count(){
46
+    public function count() {
47 47
         return $this->field("count(*) as count")->find()['count'];
48 48
     }
49
-    public function table($table){
49
+    public function table($table) {
50 50
         $this->table=$table;
51 51
         return $this;
52 52
     }
53
-    public function add($data){
54
-        return $this->db->insert($this->table,$data);
53
+    public function add($data) {
54
+        return $this->db->insert($this->table, $data);
55 55
     }
56
-    public function replace($data){
57
-        return $this->db->replace($this->table,$data);
56
+    public function replace($data) {
57
+        return $this->db->replace($this->table, $data);
58 58
     }
59
-    public function update($data){
60
-        return $this->db->update($this->table,$data);
59
+    public function update($data) {
60
+        return $this->db->update($this->table, $data);
61 61
     }
62
-    public function field($field){
62
+    public function field($field) {
63 63
         $this->field=$field;
64 64
         return $this;
65 65
     }
66
-    public function delete(){
66
+    public function delete() {
67 67
         return $this->db->delete($this->table);
68 68
     }
69
-    public function page($page,$pageLimit='10'){
69
+    public function page($page, $pageLimit='10') {
70 70
         $this->db->pageLimit=$pageLimit;
71
-        $info= $this->db->paginate($this->table,$page,$this->field);
71
+        $info=$this->db->paginate($this->table, $page, $this->field);
72 72
         return $info;
73 73
     }
74 74
 }
75 75
\ No newline at end of file
Please login to merge, or discard this patch.