소스 검색

fixed static changes

tags/0.1.0
Robin Thoni 9 년 전
부모
커밋
b80b0d1bf4
2개의 변경된 파일38개의 추가작업 그리고 13개의 파일을 삭제
  1. 4
    4
      src/Utils/LuBusiness.php
  2. 34
    9
      src/Utils/LuDataAccess.php

+ 4
- 4
src/Utils/LuBusiness.php 파일 보기

@@ -111,7 +111,7 @@ class LuBusiness {
111 111
     {
112 112
         $class = get_called_class();
113 113
         $me = new $class();
114
-        return call_user_func_array(array($me, $name), $arguments);
114
+        return call_user_func_array(array($me, '_' . $name), $arguments);
115 115
     }
116 116
 
117 117
     /**
@@ -122,7 +122,7 @@ class LuBusiness {
122 122
      * @param $query string
123 123
      * @return LuDbo[]
124 124
      */
125
-    public function search($page, $perPage, $column, $order, $query = null)
125
+    public function _search($page, $perPage, $column, $order, $query = null)
126 126
     {
127 127
         return $this->dataAccess->search($page, $perPage, $column, $order, $query);
128 128
     }
@@ -131,7 +131,7 @@ class LuBusiness {
131 131
      * @param $id int
132 132
      * @return LuDbo|null
133 133
      */
134
-    public function getById($id)
134
+    public function _getById($id)
135 135
     {
136 136
         $data = $this->dataAccess->getById($id);
137 137
         if (is_null($data))
@@ -142,7 +142,7 @@ class LuBusiness {
142 142
     /**
143 143
      * @param $id int
144 144
      */
145
-    public function deleteById($id)
145
+    public function _deleteById($id)
146 146
     {
147 147
         $this->dataAccess->deleteById($id);
148 148
     }

+ 34
- 9
src/Utils/LuDataAccess.php 파일 보기

@@ -12,7 +12,7 @@ abstract class LuDataAccess {
12 12
     {
13 13
         $class = get_called_class();
14 14
         $me = new $class();
15
-        return call_user_func_array(array($me, $name), $arguments);
15
+        return call_user_func_array(array($me, '_' . $name), $arguments);
16 16
     }
17 17
 
18 18
     /**
@@ -73,7 +73,7 @@ abstract class LuDataAccess {
73 73
      * @param $id int
74 74
      * @return LuModel
75 75
      */
76
-    protected function getModelById($id)
76
+    protected function _getModelById($id)
77 77
     {
78 78
         return $this->model->where('id', '=', $id)->first();
79 79
     }
@@ -82,9 +82,9 @@ abstract class LuDataAccess {
82 82
      * @param $id int
83 83
      * @return LuDbo|null
84 84
      */
85
-    public function getById($id)
85
+    public function _getById($id)
86 86
     {
87
-        $data = $this->getModelById($id);
87
+        $data = $this->_getModelById($id);
88 88
         if (is_null($data))
89 89
             return null;
90 90
         return $data->toDbo();
@@ -95,7 +95,7 @@ abstract class LuDataAccess {
95 95
      */
96 96
     public function deleteById($id)
97 97
     {
98
-        $data = $this->getModelById($id);
98
+        $data = $this->_getModelById($id);
99 99
         if (is_null($data))
100 100
             return;
101 101
         $data->delete();
@@ -105,7 +105,7 @@ abstract class LuDataAccess {
105 105
      * @param $data LuDbo
106 106
      * @return int
107 107
      */
108
-    public function addId($data)
108
+    public function _addId($data)
109 109
     {
110 110
         $data = $this->model->fromDBO($data);
111 111
         $data->save();
@@ -115,7 +115,7 @@ abstract class LuDataAccess {
115 115
     /**
116 116
      * @param $data LuDbo
117 117
      */
118
-    public function add($data)
118
+    public function _add($data)
119 119
     {
120 120
         $data = $this->model->fromDBO($data);
121 121
         $data->save();
@@ -126,8 +126,33 @@ abstract class LuDataAccess {
126 126
      * @param $data LuDbo
127 127
      * @return LuDbo|null
128 128
      */
129
-    public function editById($id, $data)
129
+    public function _editById($id, $data)
130 130
     {
131
-        return $this->model->fromDBO($data, $this->getModelById($id))->save();
131
+        return $this->model->fromDBO($data, $this->_getModelById($id))->save();
132
+    }
133
+
134
+    /**
135
+     * @param $predicates array
136
+     * @param $orders array
137
+     * @param int $page
138
+     * @param int $perPage
139
+     * @return array
140
+     */
141
+    public function _getMultiple($predicates, $orders, $page = 0, $perPage = PHP_INT_MAX)
142
+    {
143
+        $model = $this->model;
144
+        foreach($predicates as $predicate)
145
+        {
146
+            $model = $model->where($predicate[0], $predicate[1], $predicate[2]);
147
+        }
148
+        $count = $model->count();
149
+        foreach($orders as $order)
150
+        {
151
+            $model = $model->orderBy($order[0], $order[1]);
152
+        }
153
+        $data = $model->take($perPage)->offset($page * $perPage)->get();
154
+        $dbo = self::arrayToDbo($data);
155
+
156
+        return array("Count" => $count, "Data" => $dbo);
132 157
     }
133 158
 }

Loading…
취소
저장