@@ -30,7 +30,7 @@ |
||
30 | 30 | |
31 | 31 | public function getUserFromToken($token) |
32 | 32 | { |
33 | - if($token === false) |
|
33 | + if ($token === false) |
|
34 | 34 | { |
35 | 35 | $token = \FlipSession::getVar('OAuthToken'); |
36 | 36 | } |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | |
26 | 26 | public function getUserFromToken($token) |
27 | 27 | { |
28 | - if($token === false) |
|
28 | + if ($token === false) |
|
29 | 29 | { |
30 | 30 | $token = \FlipSession::getVar('OAuthToken'); |
31 | 31 | } |
32 | 32 | $resp = \Httpful\Request::get('https://api.github.com/user')->addHeader('Authorization', 'token '.$token['access_token'])->send(); |
33 | 33 | $github_user = $resp->body; |
34 | 34 | $user = new \Auth\PendingUser(); |
35 | - if(isset($github_user->name)) |
|
35 | + if (isset($github_user->name)) |
|
36 | 36 | { |
37 | 37 | $name = explode(' ', $github_user->name); |
38 | 38 | $user->setGivenName($name[0]); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | public function login($username, $password) |
48 | 48 | { |
49 | 49 | $resp = \Httpful\Request::post('https://profiles.test.burningflipside.com/api/v1/login?username='.urlencode($username).'&password='.urlencode($password))->send(); |
50 | - if($resp->hasErrors()) |
|
50 | + if ($resp->hasErrors()) |
|
51 | 51 | { |
52 | 52 | return false; |
53 | 53 | } |
@@ -58,11 +58,11 @@ discard block |
||
58 | 58 | |
59 | 59 | public function isLoggedIn($data) |
60 | 60 | { |
61 | - if(isset($this->user)) |
|
61 | + if (isset($this->user)) |
|
62 | 62 | { |
63 | 63 | return true; |
64 | 64 | } |
65 | - if(isset($data['res'])) |
|
65 | + if (isset($data['res'])) |
|
66 | 66 | { |
67 | 67 | return $data['res']; |
68 | 68 | } |
@@ -30,14 +30,14 @@ |
||
30 | 30 | |
31 | 31 | public function getUserFromToken($token) |
32 | 32 | { |
33 | - if($token === false) |
|
33 | + if ($token === false) |
|
34 | 34 | { |
35 | 35 | $token = \FlipSession::getVar('OAuthToken'); |
36 | 36 | } |
37 | 37 | $resp = \Httpful\Request::get('https://api.github.com/user')->addHeader('Authorization', 'token '.$token['access_token'])->send(); |
38 | 38 | $github_user = $resp->body; |
39 | 39 | $user = new \Auth\PendingUser(); |
40 | - if(isset($github_user->name)) |
|
40 | + if (isset($github_user->name)) |
|
41 | 41 | { |
42 | 42 | $name = explode(' ', $github_user->name); |
43 | 43 | $user->setGivenName($name[0]); |
@@ -10,7 +10,7 @@ |
||
10 | 10 | |
11 | 11 | public function isLoggedIn($data) |
12 | 12 | { |
13 | - if(isset($data['res'])) |
|
13 | + if (isset($data['res'])) |
|
14 | 14 | { |
15 | 15 | return $data['res']; |
16 | 16 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @SuppressWarnings("UnusedFormalParameter") |
104 | 104 | */ |
105 | - public function getGroupsByFilter($filter, $select=false, $top=false, $skip=false, $orderby=false) |
|
105 | + public function getGroupsByFilter($filter, $select = false, $top = false, $skip = false, $orderby = false) |
|
106 | 106 | { |
107 | 107 | return false; |
108 | 108 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @SuppressWarnings("UnusedFormalParameter") |
122 | 122 | */ |
123 | - public function getUsersByFilter($filter, $select=false, $top=false, $skip=false, $orderby=false) |
|
123 | + public function getUsersByFilter($filter, $select = false, $top = false, $skip = false, $orderby = false) |
|
124 | 124 | { |
125 | 125 | return false; |
126 | 126 | } |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * |
139 | 139 | * @SuppressWarnings("UnusedFormalParameter") |
140 | 140 | */ |
141 | - public function getPendingUsersByFilter($filter, $select=false, $top=false, $skip=false, $orderby=false) |
|
141 | + public function getPendingUsersByFilter($filter, $select = false, $top = false, $skip = false, $orderby = false) |
|
142 | 142 | { |
143 | 143 | return false; |
144 | 144 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | public function getActiveUserCount() |
152 | 152 | { |
153 | 153 | $users = $this->getUsersByFilter(false); |
154 | - if($users === false) |
|
154 | + if ($users === false) |
|
155 | 155 | { |
156 | 156 | return 0; |
157 | 157 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | public function getPendingUserCount() |
167 | 167 | { |
168 | 168 | $users = $this->getPendingUsersByFilter(false); |
169 | - if($users === false) |
|
169 | + if ($users === false) |
|
170 | 170 | { |
171 | 171 | return 0; |
172 | 172 | } |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | public function getGroupCount() |
182 | 182 | { |
183 | 183 | $groups = $this->getGroupsByFilter(false); |
184 | - if($groups === false) |
|
184 | + if ($groups === false) |
|
185 | 185 | { |
186 | 186 | return 0; |
187 | 187 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | private function getUserFromSession() |
27 | 27 | { |
28 | - if(FlipSession::isLoggedIn()) |
|
28 | + if (FlipSession::isLoggedIn()) |
|
29 | 29 | { |
30 | 30 | return FlipSession::getUser(); |
31 | 31 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | $auth = \AuthProvider::getInstance(); |
42 | 42 | $auth->login($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); |
43 | 43 | $user = FlipSession::getUser(); |
44 | - if($user === false) |
|
44 | + if ($user === false) |
|
45 | 45 | { |
46 | 46 | $data = substr($header['Authorization'], 6); |
47 | 47 | $userpass = explode(':', base64_decode($data)); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | private function getUserFromHeader($header) |
64 | 64 | { |
65 | - if(strncmp($header, 'Basic', 5) == 0) |
|
65 | + if (strncmp($header, 'Basic', 5) == 0) |
|
66 | 66 | { |
67 | 67 | return $this->getUserFromBasicAuth($header); |
68 | 68 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | public function call() |
73 | 73 | { |
74 | 74 | // no auth header |
75 | - if(!isset($this->headers['Authorization'])) |
|
75 | + if (!isset($this->headers['Authorization'])) |
|
76 | 76 | { |
77 | 77 | $this->app->user = $this->getUserFromSession(); |
78 | 78 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | $this->app->user = $this->getUserFromHeader($header); |
83 | 83 | } |
84 | 84 | |
85 | - if($this->app->user === false) |
|
85 | + if ($this->app->user === false) |
|
86 | 86 | { |
87 | 87 | $this->app->getLog()->error("No user found for call"); |
88 | 88 | } |
@@ -96,19 +96,19 @@ discard block |
||
96 | 96 | { |
97 | 97 | private function fix_encoded_element($key, $value, &$array, $prefix = '') |
98 | 98 | { |
99 | - if(is_array($value)) |
|
99 | + if (is_array($value)) |
|
100 | 100 | { |
101 | 101 | $array[$key] = implode(';', $value); |
102 | 102 | } |
103 | - else if($key === '_id' && is_object($value)) |
|
103 | + else if ($key === '_id' && is_object($value)) |
|
104 | 104 | { |
105 | 105 | $array[$key] = $value->{'$id'}; |
106 | 106 | } |
107 | - else if(is_object($value)) |
|
107 | + else if (is_object($value)) |
|
108 | 108 | { |
109 | 109 | $array[$key] = $this->app->request->getUrl().$this->app->request->getPath().$prefix.'/'.$key; |
110 | 110 | } |
111 | - else if(strncmp($value, 'data:', 5) === 0) |
|
111 | + else if (strncmp($value, 'data:', 5) === 0) |
|
112 | 112 | { |
113 | 113 | $array[$key] = $this->app->request->getUrl().$this->app->request->getPath().$prefix.'/'.$key; |
114 | 114 | } |
@@ -122,40 +122,40 @@ discard block |
||
122 | 122 | } |
123 | 123 | ob_start(); |
124 | 124 | $df = fopen("php://output", 'w'); |
125 | - if(is_array($array)) |
|
125 | + if (is_array($array)) |
|
126 | 126 | { |
127 | 127 | $first = reset($array); |
128 | 128 | $keys = FALSE; |
129 | - if(is_array($first)) |
|
129 | + if (is_array($first)) |
|
130 | 130 | { |
131 | 131 | $keys = array_keys($first); |
132 | 132 | } |
133 | - else if(is_object($first)) |
|
133 | + else if (is_object($first)) |
|
134 | 134 | { |
135 | 135 | $keys = array_keys(get_object_vars($first)); |
136 | 136 | } |
137 | 137 | fputcsv($df, $keys); |
138 | 138 | foreach ($array as $row) |
139 | 139 | { |
140 | - if(is_array($row)) |
|
140 | + if (is_array($row)) |
|
141 | 141 | { |
142 | 142 | $id = $row[$keys[0]]; |
143 | - foreach($row as $key=>$value) |
|
143 | + foreach ($row as $key=>$value) |
|
144 | 144 | { |
145 | 145 | $this->fix_encoded_element($key, $value, $row, '/'.$id); |
146 | 146 | } |
147 | 147 | fputcsv($df, $row); |
148 | 148 | } |
149 | - else if(is_object($row)) |
|
149 | + else if (is_object($row)) |
|
150 | 150 | { |
151 | 151 | $keyName = $keys[0]; |
152 | 152 | $id = $row->$keyName; |
153 | - if(is_object($id)) |
|
153 | + if (is_object($id)) |
|
154 | 154 | { |
155 | 155 | $id = $id->{'$id'}; |
156 | 156 | } |
157 | 157 | $values = get_object_vars($row); |
158 | - foreach($values as $key=>$value) |
|
158 | + foreach ($values as $key=>$value) |
|
159 | 159 | { |
160 | 160 | $this->fix_encoded_element($key, $value, $values, '/'.$id); |
161 | 161 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | { |
168 | 168 | $array = get_object_vars($array); |
169 | 169 | fputcsv($df, array_keys($array)); |
170 | - foreach($array as $key=>$value) |
|
170 | + foreach ($array as $key=>$value) |
|
171 | 171 | { |
172 | 172 | $this->fix_encoded_element($key, $value, $array); |
173 | 173 | } |
@@ -185,34 +185,34 @@ discard block |
||
185 | 185 | |
186 | 186 | public function call() |
187 | 187 | { |
188 | - if($this->app->request->isOptions()) |
|
188 | + if ($this->app->request->isOptions()) |
|
189 | 189 | { |
190 | 190 | return; |
191 | 191 | } |
192 | 192 | $params = $this->app->request->params(); |
193 | 193 | $fmt = null; |
194 | - if(isset($params['fmt'])) |
|
194 | + if (isset($params['fmt'])) |
|
195 | 195 | { |
196 | 196 | $fmt = $params['fmt']; |
197 | 197 | } |
198 | - if($fmt === null && isset($params['$format'])) |
|
198 | + if ($fmt === null && isset($params['$format'])) |
|
199 | 199 | { |
200 | 200 | $fmt = $params['$format']; |
201 | - if(strstr($fmt, 'odata.streaming=true')) |
|
201 | + if (strstr($fmt, 'odata.streaming=true')) |
|
202 | 202 | { |
203 | 203 | $this->app->response->setStatus(406); |
204 | 204 | return; |
205 | 205 | } |
206 | 206 | } |
207 | - if($fmt === null) |
|
207 | + if ($fmt === null) |
|
208 | 208 | { |
209 | 209 | $mimeType = $this->app->request->headers->get('Accept'); |
210 | - if(strstr($mimeType, 'odata.streaming=true')) |
|
210 | + if (strstr($mimeType, 'odata.streaming=true')) |
|
211 | 211 | { |
212 | 212 | $this->app->response->setStatus(406); |
213 | 213 | return; |
214 | 214 | } |
215 | - switch($mimeType) |
|
215 | + switch ($mimeType) |
|
216 | 216 | { |
217 | 217 | case 'text/csv': |
218 | 218 | $fmt = 'csv'; |
@@ -232,11 +232,11 @@ discard block |
||
232 | 232 | |
233 | 233 | $this->next->call(); |
234 | 234 | |
235 | - if($this->app->response->getStatus() == 200 && $this->app->fmt !== 'json') |
|
235 | + if ($this->app->response->getStatus() == 200 && $this->app->fmt !== 'json') |
|
236 | 236 | { |
237 | 237 | $data = json_decode($this->app->response->getBody()); |
238 | 238 | $text = ''; |
239 | - switch($this->app->fmt) |
|
239 | + switch ($this->app->fmt) |
|
240 | 240 | { |
241 | 241 | case 'data-table': |
242 | 242 | $this->app->response->headers->set('Content-Type', 'application/json'); |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | } |
264 | 264 | $this->app->response->setBody($text); |
265 | 265 | } |
266 | - else if($this->app->response->getStatus() == 200) |
|
266 | + else if ($this->app->response->getStatus() == 200) |
|
267 | 267 | { |
268 | 268 | $this->app->response->headers->set('Content-Type', 'application/json;odata.metadata=none'); |
269 | 269 | } |
@@ -293,12 +293,12 @@ discard block |
||
293 | 293 | return $this->post($uri, $handler); |
294 | 294 | } |
295 | 295 | |
296 | - function get_json_body($array=false) |
|
296 | + function get_json_body($array = false) |
|
297 | 297 | { |
298 | 298 | return $this->getJsonBody($array); |
299 | 299 | } |
300 | 300 | |
301 | - function getJsonBody($array=false) |
|
301 | + function getJsonBody($array = false) |
|
302 | 302 | { |
303 | 303 | $body = $this->request->getBody(); |
304 | 304 | return json_decode($body, $array); |
@@ -26,16 +26,16 @@ |
||
26 | 26 | { |
27 | 27 | $namespace = substr($classname, 0, $lastNsPos); |
28 | 28 | $classname = substr($classname, $lastNsPos + 1); |
29 | - $filename = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR; |
|
29 | + $filename = str_replace('\\', DIRECTORY_SEPARATOR, $namespace).DIRECTORY_SEPARATOR; |
|
30 | 30 | } |
31 | 31 | $filename = __DIR__.DIRECTORY_SEPARATOR.$filename.'class.'.$classname.'.php'; |
32 | - if(is_readable($filename)) |
|
32 | + if (is_readable($filename)) |
|
33 | 33 | { |
34 | 34 | require $filename; |
35 | 35 | } |
36 | 36 | } |
37 | 37 | |
38 | -if(version_compare(PHP_VERSION, '5.3.0', '>=')) |
|
38 | +if (version_compare(PHP_VERSION, '5.3.0', '>=')) |
|
39 | 39 | { |
40 | 40 | spl_autoload_register('FlipsideAutoload', true, true); |
41 | 41 | } |
@@ -5,18 +5,18 @@ discard block |
||
5 | 5 | { |
6 | 6 | protected $data = null; |
7 | 7 | |
8 | - function count($filter=false) |
|
8 | + function count($filter = false) |
|
9 | 9 | { |
10 | 10 | throw new \Exception('Unimplemented'); |
11 | 11 | } |
12 | 12 | |
13 | - function search($filter=false, $select=false, $count=false, $skip=false, $sort=false, $params=false) |
|
13 | + function search($filter = false, $select = false, $count = false, $skip = false, $sort = false, $params = false) |
|
14 | 14 | { |
15 | - if($this->data === null) |
|
15 | + if ($this->data === null) |
|
16 | 16 | { |
17 | 17 | throw new \Exception('Unimplemented'); |
18 | 18 | } |
19 | - if($filter !== false) |
|
19 | + if ($filter !== false) |
|
20 | 20 | { |
21 | 21 | $array = $filter->filter_array($this->data); |
22 | 22 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | throw new \Exception('Unimplemented'); |
29 | 29 | } |
30 | 30 | |
31 | - function read($filter=false, $select=false, $count=false, $skip=false, $sort=false, $params=false) |
|
31 | + function read($filter = false, $select = false, $count = false, $skip = false, $sort = false, $params = false) |
|
32 | 32 | { |
33 | 33 | return $this->search($filter, $select, $count, $skip, $sort, $params); |
34 | 34 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | |
8 | 8 | function __construct($params) |
9 | 9 | { |
10 | - if(isset($params['user'])) |
|
10 | + if (isset($params['user'])) |
|
11 | 11 | { |
12 | 12 | $this->pdo = new \PDO($params['dsn'], $params['user'], $params['pass']); |
13 | 13 | } |
@@ -20,12 +20,12 @@ discard block |
||
20 | 20 | function _get_row_count_for_query($sql) |
21 | 21 | { |
22 | 22 | $stmt = $this->pdo->query($sql); |
23 | - if($stmt === false) |
|
23 | + if ($stmt === false) |
|
24 | 24 | { |
25 | 25 | return 0; |
26 | 26 | } |
27 | 27 | $count = $stmt->rowCount(); |
28 | - if($count === 0) |
|
28 | + if ($count === 0) |
|
29 | 29 | { |
30 | 30 | $array = $stmt->fetchAll(); |
31 | 31 | $count = count($array); |
@@ -35,11 +35,11 @@ discard block |
||
35 | 35 | |
36 | 36 | function _tableExistsNoPrefix($name) |
37 | 37 | { |
38 | - if($this->_get_row_count_for_query('SHOW TABLES LIKE '.$this->pdo->quote($name)) > 0) |
|
38 | + if ($this->_get_row_count_for_query('SHOW TABLES LIKE '.$this->pdo->quote($name)) > 0) |
|
39 | 39 | { |
40 | 40 | return true; |
41 | 41 | } |
42 | - else if($this->_get_row_count_for_query('SELECT * FROM sqlite_master WHERE name LIKE '.$this->pdo->quote($name)) > 0) |
|
42 | + else if ($this->_get_row_count_for_query('SELECT * FROM sqlite_master WHERE name LIKE '.$this->pdo->quote($name)) > 0) |
|
43 | 43 | { |
44 | 44 | return true; |
45 | 45 | } |
@@ -48,11 +48,11 @@ discard block |
||
48 | 48 | |
49 | 49 | function _tableExists($name) |
50 | 50 | { |
51 | - if($this->_get_row_count_for_query('SHOW TABLES LIKE '.$this->pdo->quote('tbl'.$name)) > 0) |
|
51 | + if ($this->_get_row_count_for_query('SHOW TABLES LIKE '.$this->pdo->quote('tbl'.$name)) > 0) |
|
52 | 52 | { |
53 | 53 | return true; |
54 | 54 | } |
55 | - else if($this->_get_row_count_for_query('SELECT * FROM sqlite_master WHERE name LIKE '.$this->pdo->quote('tbl'.$name)) > 0) |
|
55 | + else if ($this->_get_row_count_for_query('SELECT * FROM sqlite_master WHERE name LIKE '.$this->pdo->quote('tbl'.$name)) > 0) |
|
56 | 56 | { |
57 | 57 | return true; |
58 | 58 | } |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | |
62 | 62 | function _viewExists($name) |
63 | 63 | { |
64 | - if($this->_get_row_count_for_query('SHOW TABLES LIKE '.$this->pdo->quote('v'.$name)) > 0) |
|
64 | + if ($this->_get_row_count_for_query('SHOW TABLES LIKE '.$this->pdo->quote('v'.$name)) > 0) |
|
65 | 65 | { |
66 | 66 | return true; |
67 | 67 | } |
68 | - else if($this->_get_row_count_for_query('SELECT * FROM sqlite_master WHERE name LIKE '.$this->pdo->quote('v'.$name)) > 0) |
|
68 | + else if ($this->_get_row_count_for_query('SELECT * FROM sqlite_master WHERE name LIKE '.$this->pdo->quote('v'.$name)) > 0) |
|
69 | 69 | { |
70 | 70 | return true; |
71 | 71 | } |
@@ -74,15 +74,15 @@ discard block |
||
74 | 74 | |
75 | 75 | function tableExists($name) |
76 | 76 | { |
77 | - if($this->_tableExists($name)) |
|
77 | + if ($this->_tableExists($name)) |
|
78 | 78 | { |
79 | 79 | return true; |
80 | 80 | } |
81 | - if($this->_tableExistsNoPrefix($name)) |
|
81 | + if ($this->_tableExistsNoPrefix($name)) |
|
82 | 82 | { |
83 | 83 | return true; |
84 | 84 | } |
85 | - if($this->_viewExists($name)) |
|
85 | + if ($this->_viewExists($name)) |
|
86 | 86 | { |
87 | 87 | return true; |
88 | 88 | } |
@@ -91,60 +91,60 @@ discard block |
||
91 | 91 | |
92 | 92 | function getTable($name) |
93 | 93 | { |
94 | - if($this->_tableExists($name)) |
|
94 | + if ($this->_tableExists($name)) |
|
95 | 95 | { |
96 | 96 | return new SQLDataTable($this, 'tbl'.$name); |
97 | 97 | } |
98 | - if($this->_viewExists($name)) |
|
98 | + if ($this->_viewExists($name)) |
|
99 | 99 | { |
100 | 100 | return new SQLDataTable($this, 'v'.$name); |
101 | 101 | } |
102 | - if($this->_tableExistsNoPrefix($name)) |
|
102 | + if ($this->_tableExistsNoPrefix($name)) |
|
103 | 103 | { |
104 | 104 | return new SQLDataTable($this, $name); |
105 | 105 | } |
106 | 106 | throw new \Exception('No such table '.$name); |
107 | 107 | } |
108 | 108 | |
109 | - function read($tablename, $where=false, $select='*', $count=false, $skip=false, $sort=false) |
|
109 | + function read($tablename, $where = false, $select = '*', $count = false, $skip = false, $sort = false) |
|
110 | 110 | { |
111 | - if($select === false) |
|
111 | + if ($select === false) |
|
112 | 112 | { |
113 | 113 | $select = '*'; |
114 | 114 | } |
115 | 115 | $sql = "SELECT $select FROM $tablename"; |
116 | - if($where !== false) |
|
116 | + if ($where !== false) |
|
117 | 117 | { |
118 | - $sql.=' WHERE '.$where; |
|
118 | + $sql .= ' WHERE '.$where; |
|
119 | 119 | } |
120 | - if($count !== false) |
|
120 | + if ($count !== false) |
|
121 | 121 | { |
122 | - if($skip === false) |
|
122 | + if ($skip === false) |
|
123 | 123 | { |
124 | - $sql.=' LIMIT '.(int)$count; |
|
124 | + $sql .= ' LIMIT '.(int)$count; |
|
125 | 125 | } |
126 | 126 | else |
127 | 127 | { |
128 | - $sql.=" LIMIT $skip, $count"; |
|
128 | + $sql .= " LIMIT $skip, $count"; |
|
129 | 129 | } |
130 | 130 | } |
131 | - if($sort !== false) |
|
131 | + if ($sort !== false) |
|
132 | 132 | { |
133 | - $sql.=' ORDER BY '; |
|
133 | + $sql .= ' ORDER BY '; |
|
134 | 134 | $tmp = array(); |
135 | - foreach($sort as $sort_col=>$dir) |
|
135 | + foreach ($sort as $sort_col=>$dir) |
|
136 | 136 | { |
137 | - array_push($tmp, $sort_col.' '.($dir === 1?'ASC':'DESC')); |
|
137 | + array_push($tmp, $sort_col.' '.($dir === 1 ? 'ASC' : 'DESC')); |
|
138 | 138 | } |
139 | - $sql.=implode($tmp,','); |
|
139 | + $sql .= implode($tmp, ','); |
|
140 | 140 | } |
141 | 141 | $stmt = $this->pdo->query($sql, \PDO::FETCH_ASSOC); |
142 | - if($stmt === false) |
|
142 | + if ($stmt === false) |
|
143 | 143 | { |
144 | 144 | return false; |
145 | 145 | } |
146 | 146 | $ret = $stmt->fetchAll(); |
147 | - if($ret === false || empty($ret)) |
|
147 | + if ($ret === false || empty($ret)) |
|
148 | 148 | { |
149 | 149 | return false; |
150 | 150 | } |
@@ -154,19 +154,19 @@ discard block |
||
154 | 154 | function update($tablename, $where, $data) |
155 | 155 | { |
156 | 156 | $set = array(); |
157 | - if(is_object($data)) |
|
157 | + if (is_object($data)) |
|
158 | 158 | { |
159 | 159 | $data = (array)$data; |
160 | 160 | } |
161 | 161 | $cols = array_keys($data); |
162 | 162 | $count = count($cols); |
163 | - for($i = 0; $i < $count; $i++) |
|
163 | + for ($i = 0; $i < $count; $i++) |
|
164 | 164 | { |
165 | 165 | array_push($set, $cols[$i].'='.$this->pdo->quote($data[$cols[$i]])); |
166 | 166 | } |
167 | 167 | $set = implode(',', $set); |
168 | 168 | $sql = "UPDATE $tablename SET $set WHERE $where"; |
169 | - if($this->pdo->exec($sql) === false) |
|
169 | + if ($this->pdo->exec($sql) === false) |
|
170 | 170 | { |
171 | 171 | return false; |
172 | 172 | } |
@@ -176,20 +176,20 @@ discard block |
||
176 | 176 | function create($tablename, $data) |
177 | 177 | { |
178 | 178 | $set = array(); |
179 | - if(is_object($data)) |
|
179 | + if (is_object($data)) |
|
180 | 180 | { |
181 | 181 | $data = (array)$data; |
182 | 182 | } |
183 | 183 | $cols = array_keys($data); |
184 | 184 | $count = count($cols); |
185 | - for($i = 0; $i < $count; $i++) |
|
185 | + for ($i = 0; $i < $count; $i++) |
|
186 | 186 | { |
187 | 187 | array_push($set, $this->pdo->quote($data[$cols[$i]])); |
188 | 188 | } |
189 | 189 | $cols = implode(',', $cols); |
190 | 190 | $set = implode(',', $set); |
191 | 191 | $sql = "INSERT INTO $tablename ($cols) VALUES ($set);"; |
192 | - if($this->pdo->exec($sql) === false) |
|
192 | + if ($this->pdo->exec($sql) === false) |
|
193 | 193 | { |
194 | 194 | return false; |
195 | 195 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | function delete($tablename, $where) |
200 | 200 | { |
201 | 201 | $sql = "DELETE FROM $tablename WHERE $where"; |
202 | - if($this->pdo->exec($sql) === false) |
|
202 | + if ($this->pdo->exec($sql) === false) |
|
203 | 203 | { |
204 | 204 | return false; |
205 | 205 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | function raw_query($sql) |
210 | 210 | { |
211 | 211 | $stmt = $this->pdo->query($sql, \PDO::FETCH_ASSOC); |
212 | - if($stmt === false) |
|
212 | + if ($stmt === false) |
|
213 | 213 | { |
214 | 214 | return false; |
215 | 215 | } |