@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | /** |
56 | 56 | * Return whether support or not support cache |
57 | 57 | * |
58 | - * @return true |
|
58 | + * @return boolean |
|
59 | 59 | */ |
60 | 60 | function isSupport() |
61 | 61 | { |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | /** |
165 | 165 | * Truncate all existing variables at the cache |
166 | 166 | * |
167 | - * @return bool Returns true on success or false on failure. |
|
167 | + * @return boolean|null Returns true on success or false on failure. |
|
168 | 168 | */ |
169 | 169 | function truncate() |
170 | 170 | { |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | function getInstance() |
25 | 25 | { |
26 | - if(!$GLOBALS['__CacheFile__']) |
|
26 | + if (!$GLOBALS['__CacheFile__']) |
|
27 | 27 | { |
28 | 28 | $GLOBALS['__CacheFile__'] = new CacheFile(); |
29 | 29 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | function __construct() |
39 | 39 | { |
40 | - $this->cache_dir = _XE_PATH_ . $this->cache_dir; |
|
40 | + $this->cache_dir = _XE_PATH_.$this->cache_dir; |
|
41 | 41 | FileHandler::makeDir($this->cache_dir); |
42 | 42 | } |
43 | 43 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | */ |
50 | 50 | function getCacheFileName($key) |
51 | 51 | { |
52 | - return $this->cache_dir . str_replace(':', DIRECTORY_SEPARATOR, $key) . '.php'; |
|
52 | + return $this->cache_dir.str_replace(':', DIRECTORY_SEPARATOR, $key).'.php'; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | $content = array(); |
77 | 77 | $content[] = '<?php'; |
78 | 78 | $content[] = 'if(!defined(\'__XE__\')) { exit(); }'; |
79 | - $content[] = 'return \'' . addslashes(serialize($obj)) . '\';'; |
|
79 | + $content[] = 'return \''.addslashes(serialize($obj)).'\';'; |
|
80 | 80 | FileHandler::writeFile($cache_file, implode(PHP_EOL, $content)); |
81 | - if(function_exists('opcache_invalidate')) |
|
81 | + if (function_exists('opcache_invalidate')) |
|
82 | 82 | { |
83 | 83 | @opcache_invalidate($cache_file, true); |
84 | 84 | } |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | { |
96 | 96 | $cache_file = $this->getCacheFileName($key); |
97 | 97 | |
98 | - if(file_exists($cache_file)) |
|
98 | + if (file_exists($cache_file)) |
|
99 | 99 | { |
100 | - if($modified_time > 0 && filemtime($cache_file) < $modified_time) |
|
100 | + if ($modified_time > 0 && filemtime($cache_file) < $modified_time) |
|
101 | 101 | { |
102 | 102 | FileHandler::removeFile($cache_file); |
103 | 103 | return false; |
@@ -118,12 +118,12 @@ discard block |
||
118 | 118 | */ |
119 | 119 | function get($key, $modified_time = 0) |
120 | 120 | { |
121 | - if(!$cache_file = FileHandler::exists($this->getCacheFileName($key))) |
|
121 | + if (!$cache_file = FileHandler::exists($this->getCacheFileName($key))) |
|
122 | 122 | { |
123 | 123 | return false; |
124 | 124 | } |
125 | 125 | |
126 | - if($modified_time > 0 && filemtime($cache_file) < $modified_time) |
|
126 | + if ($modified_time > 0 && filemtime($cache_file) < $modified_time) |
|
127 | 127 | { |
128 | 128 | FileHandler::removeFile($cache_file); |
129 | 129 | return false; |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | function _delete($_key) |
144 | 144 | { |
145 | 145 | $cache_file = $this->getCacheFileName($_key); |
146 | - if(function_exists('opcache_invalidate')) |
|
146 | + if (function_exists('opcache_invalidate')) |
|
147 | 147 | { |
148 | 148 | @opcache_invalidate($cache_file, true); |
149 | 149 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | * |
36 | 36 | * Do not use this directly. You can use getInstance() instead. |
37 | 37 | * @param string $url url of memcache |
38 | - * @return void |
|
38 | + * @return false|null |
|
39 | 39 | */ |
40 | 40 | function __construct($url) |
41 | 41 | { |
@@ -97,6 +97,9 @@ |
||
97 | 97 | return $this->pipe . ' ' . $this->getConditionPart($this->_value); |
98 | 98 | } |
99 | 99 | |
100 | + /** |
|
101 | + * @param string $pipe |
|
102 | + */ |
|
100 | 103 | function setPipe($pipe) |
101 | 104 | { |
102 | 105 | $this->pipe = $pipe; |
@@ -61,13 +61,13 @@ discard block |
||
61 | 61 | */ |
62 | 62 | function toString($withValue = true) |
63 | 63 | { |
64 | - if(!isset($this->_value_to_string)) |
|
64 | + if (!isset($this->_value_to_string)) |
|
65 | 65 | { |
66 | - if(!$this->show()) |
|
66 | + if (!$this->show()) |
|
67 | 67 | { |
68 | 68 | $this->_value_to_string = ''; |
69 | 69 | } |
70 | - else if($withValue) |
|
70 | + else if ($withValue) |
|
71 | 71 | { |
72 | 72 | $this->_value_to_string = $this->toStringWithValue(); |
73 | 73 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | function toStringWithoutValue() |
87 | 87 | { |
88 | - return $this->pipe . ' ' . $this->getConditionPart($this->_value); |
|
88 | + return $this->pipe.' '.$this->getConditionPart($this->_value); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | function toStringWithValue() |
96 | 96 | { |
97 | - return $this->pipe . ' ' . $this->getConditionPart($this->_value); |
|
97 | + return $this->pipe.' '.$this->getConditionPart($this->_value); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | function setPipe($pipe) |
@@ -107,16 +107,16 @@ discard block |
||
107 | 107 | */ |
108 | 108 | function show() |
109 | 109 | { |
110 | - if(!isset($this->_show)) |
|
110 | + if (!isset($this->_show)) |
|
111 | 111 | { |
112 | - if(is_array($this->_value) && count($this->_value) === 1 && $this->_value[0] === '') |
|
112 | + if (is_array($this->_value) && count($this->_value) === 1 && $this->_value[0] === '') |
|
113 | 113 | { |
114 | 114 | $this->_show = false; |
115 | 115 | } |
116 | 116 | else |
117 | 117 | { |
118 | 118 | $this->_show = true; |
119 | - switch($this->operation) |
|
119 | + switch ($this->operation) |
|
120 | 120 | { |
121 | 121 | case 'equal' : |
122 | 122 | case 'more' : |
@@ -138,30 +138,30 @@ discard block |
||
138 | 138 | case 'not': |
139 | 139 | case 'notequal' : |
140 | 140 | // if variable is not set or is not string or number, return |
141 | - if(!isset($this->_value)) |
|
141 | + if (!isset($this->_value)) |
|
142 | 142 | { |
143 | 143 | $this->_show = false; |
144 | 144 | break; |
145 | 145 | } |
146 | - if($this->_value === '') |
|
146 | + if ($this->_value === '') |
|
147 | 147 | { |
148 | 148 | $this->_show = false; |
149 | 149 | break; |
150 | 150 | } |
151 | 151 | $tmpArray = array('string' => 1, 'integer' => 1); |
152 | - if(!isset($tmpArray[gettype($this->_value)])) |
|
152 | + if (!isset($tmpArray[gettype($this->_value)])) |
|
153 | 153 | { |
154 | 154 | $this->_show = false; |
155 | 155 | break; |
156 | 156 | } |
157 | 157 | break; |
158 | 158 | case 'between' : |
159 | - if(!is_array($this->_value)) |
|
159 | + if (!is_array($this->_value)) |
|
160 | 160 | { |
161 | 161 | $this->_show = false; |
162 | 162 | break; |
163 | 163 | } |
164 | - if(count($this->_value) != 2) |
|
164 | + if (count($this->_value) != 2) |
|
165 | 165 | { |
166 | 166 | $this->_show = false; |
167 | 167 | break; |
@@ -188,67 +188,67 @@ discard block |
||
188 | 188 | $name = $this->column_name; |
189 | 189 | $operation = $this->operation; |
190 | 190 | |
191 | - switch($operation) |
|
191 | + switch ($operation) |
|
192 | 192 | { |
193 | 193 | case 'equal' : |
194 | - return $name . ' = ' . $value; |
|
194 | + return $name.' = '.$value; |
|
195 | 195 | break; |
196 | 196 | case 'more' : |
197 | - return $name . ' >= ' . $value; |
|
197 | + return $name.' >= '.$value; |
|
198 | 198 | break; |
199 | 199 | case 'excess' : |
200 | - return $name . ' > ' . $value; |
|
200 | + return $name.' > '.$value; |
|
201 | 201 | break; |
202 | 202 | case 'less' : |
203 | - return $name . ' <= ' . $value; |
|
203 | + return $name.' <= '.$value; |
|
204 | 204 | break; |
205 | 205 | case 'below' : |
206 | - return $name . ' < ' . $value; |
|
206 | + return $name.' < '.$value; |
|
207 | 207 | break; |
208 | 208 | case 'like_tail' : |
209 | 209 | case 'like_prefix' : |
210 | 210 | case 'like' : |
211 | - if(defined('__CUBRID_VERSION__') |
|
211 | + if (defined('__CUBRID_VERSION__') |
|
212 | 212 | && __CUBRID_VERSION__ >= '8.4.1') |
213 | - return $name . ' rlike ' . $value; |
|
213 | + return $name.' rlike '.$value; |
|
214 | 214 | else |
215 | - return $name . ' like ' . $value; |
|
215 | + return $name.' like '.$value; |
|
216 | 216 | break; |
217 | 217 | case 'notlike_tail' : |
218 | 218 | case 'notlike_prefix' : |
219 | 219 | case 'notlike' : |
220 | - return $name . ' not like ' . $value; |
|
220 | + return $name.' not like '.$value; |
|
221 | 221 | break; |
222 | 222 | case 'in' : |
223 | - return $name . ' in ' . $value; |
|
223 | + return $name.' in '.$value; |
|
224 | 224 | break; |
225 | 225 | case 'notin' : |
226 | 226 | case 'not_in' : |
227 | - return $name . ' not in ' . $value; |
|
227 | + return $name.' not in '.$value; |
|
228 | 228 | break; |
229 | 229 | case 'notequal' : |
230 | - return $name . ' <> ' . $value; |
|
230 | + return $name.' <> '.$value; |
|
231 | 231 | break; |
232 | 232 | case 'notnull' : |
233 | - return $name . ' is not null'; |
|
233 | + return $name.' is not null'; |
|
234 | 234 | break; |
235 | 235 | case 'null' : |
236 | - return $name . ' is null'; |
|
236 | + return $name.' is null'; |
|
237 | 237 | break; |
238 | 238 | case 'and' : |
239 | - return $name . ' & ' . $value; |
|
239 | + return $name.' & '.$value; |
|
240 | 240 | break; |
241 | 241 | case 'or' : |
242 | - return $name . ' | ' . $value; |
|
242 | + return $name.' | '.$value; |
|
243 | 243 | break; |
244 | 244 | case 'xor' : |
245 | - return $name . ' ^ ' . $value; |
|
245 | + return $name.' ^ '.$value; |
|
246 | 246 | break; |
247 | 247 | case 'not' : |
248 | - return $name . ' ~ ' . $value; |
|
248 | + return $name.' ~ '.$value; |
|
249 | 249 | break; |
250 | 250 | case 'between' : |
251 | - return $name . ' between ' . $value[0] . ' and ' . $value[1]; |
|
251 | + return $name.' between '.$value[0].' and '.$value[1]; |
|
252 | 252 | break; |
253 | 253 | } |
254 | 254 | } |
@@ -66,12 +66,10 @@ discard block |
||
66 | 66 | if(!$this->show()) |
67 | 67 | { |
68 | 68 | $this->_value_to_string = ''; |
69 | - } |
|
70 | - else if($withValue) |
|
69 | + } else if($withValue) |
|
71 | 70 | { |
72 | 71 | $this->_value_to_string = $this->toStringWithValue(); |
73 | - } |
|
74 | - else |
|
72 | + } else |
|
75 | 73 | { |
76 | 74 | $this->_value_to_string = $this->toStringWithoutValue(); |
77 | 75 | } |
@@ -112,8 +110,7 @@ discard block |
||
112 | 110 | if(is_array($this->_value) && count($this->_value) === 1 && $this->_value[0] === '') |
113 | 111 | { |
114 | 112 | $this->_show = false; |
115 | - } |
|
116 | - else |
|
113 | + } else |
|
117 | 114 | { |
118 | 115 | $this->_show = true; |
119 | 116 | switch($this->operation) |
@@ -209,10 +206,11 @@ discard block |
||
209 | 206 | case 'like_prefix' : |
210 | 207 | case 'like' : |
211 | 208 | if(defined('__CUBRID_VERSION__') |
212 | - && __CUBRID_VERSION__ >= '8.4.1') |
|
213 | - return $name . ' rlike ' . $value; |
|
214 | - else |
|
215 | - return $name . ' like ' . $value; |
|
209 | + && __CUBRID_VERSION__ >= '8.4.1') { |
|
210 | + return $name . ' rlike ' . $value; |
|
211 | + } else { |
|
212 | + return $name . ' like ' . $value; |
|
213 | + } |
|
216 | 214 | break; |
217 | 215 | case 'notlike_tail' : |
218 | 216 | case 'notlike_prefix' : |
@@ -12,10 +12,10 @@ |
||
12 | 12 | /** |
13 | 13 | * constructor |
14 | 14 | * @param string $column_name |
15 | - * @param mixed $argument |
|
15 | + * @param integer $argument |
|
16 | 16 | * @param string $operation |
17 | 17 | * @param string $pipe |
18 | - * @return void |
|
18 | + * @return boolean |
|
19 | 19 | */ |
20 | 20 | function __construct($column_name, $argument, $operation, $pipe = "") |
21 | 21 | { |
@@ -21,13 +21,13 @@ |
||
21 | 21 | { |
22 | 22 | parent::__construct($column_name, $argument, $operation, $pipe); |
23 | 23 | $tmpArray = array('in' => 1, 'notin' => 1, 'not_in' => 1); |
24 | - if(isset($tmpArray[$operation])) |
|
24 | + if (isset($tmpArray[$operation])) |
|
25 | 25 | { |
26 | - if(is_array($argument)) |
|
26 | + if (is_array($argument)) |
|
27 | 27 | { |
28 | 28 | $argument = implode($argument, ','); |
29 | 29 | } |
30 | - $this->_value = '(' . $argument . ')'; |
|
30 | + $this->_value = '('.$argument.')'; |
|
31 | 31 | } |
32 | 32 | else |
33 | 33 | { |
@@ -28,8 +28,7 @@ |
||
28 | 28 | $argument = implode($argument, ','); |
29 | 29 | } |
30 | 30 | $this->_value = '(' . $argument . ')'; |
31 | - } |
|
32 | - else |
|
31 | + } else |
|
33 | 32 | { |
34 | 33 | $this->_value = $argument; |
35 | 34 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | /** |
21 | 21 | * constructor |
22 | 22 | * @param string $column_name |
23 | - * @param object $argument |
|
23 | + * @param Argument $argument |
|
24 | 24 | * @return void |
25 | 25 | */ |
26 | 26 | function __construct($column_name, $argument) |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | function getExpression($with_value = true) |
37 | 37 | { |
38 | - if($with_value) |
|
38 | + if ($with_value) |
|
39 | 39 | { |
40 | 40 | return $this->getExpressionWithValue(); |
41 | 41 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | { |
51 | 51 | $value = $this->argument->getValue(); |
52 | 52 | $operation = $this->argument->getColumnOperation(); |
53 | - if(isset($operation)) |
|
53 | + if (isset($operation)) |
|
54 | 54 | { |
55 | 55 | return "$this->column_name = $this->column_name $operation $value"; |
56 | 56 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | function getExpressionWithoutValue() |
66 | 66 | { |
67 | 67 | $operation = $this->argument->getColumnOperation(); |
68 | - if(isset($operation)) |
|
68 | + if (isset($operation)) |
|
69 | 69 | { |
70 | 70 | return "$this->column_name = $this->column_name $operation ?"; |
71 | 71 | } |
@@ -76,21 +76,21 @@ discard block |
||
76 | 76 | { |
77 | 77 | // TODO Escape value according to column type instead of variable type |
78 | 78 | $value = $this->argument->getValue(); |
79 | - if(!is_numeric($value)) |
|
79 | + if (!is_numeric($value)) |
|
80 | 80 | { |
81 | - return "'" . $value . "'"; |
|
81 | + return "'".$value."'"; |
|
82 | 82 | } |
83 | 83 | return $value; |
84 | 84 | } |
85 | 85 | |
86 | 86 | function show() |
87 | 87 | { |
88 | - if(!$this->argument) |
|
88 | + if (!$this->argument) |
|
89 | 89 | { |
90 | 90 | return false; |
91 | 91 | } |
92 | 92 | $value = $this->argument->getValue(); |
93 | - if(!isset($value)) |
|
93 | + if (!isset($value)) |
|
94 | 94 | { |
95 | 95 | return false; |
96 | 96 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | |
105 | 105 | function getArguments() |
106 | 106 | { |
107 | - if($this->argument) |
|
107 | + if ($this->argument) |
|
108 | 108 | { |
109 | 109 | return array($this->argument); |
110 | 110 | } |
@@ -62,8 +62,7 @@ |
||
62 | 62 | if($this->argument) |
63 | 63 | { |
64 | 64 | return array($this->argument); |
65 | - } |
|
66 | - else |
|
65 | + } else |
|
67 | 66 | { |
68 | 67 | return array(); |
69 | 68 | } |
@@ -128,7 +128,7 @@ |
||
128 | 128 | /** |
129 | 129 | * Constructor function |
130 | 130 | * |
131 | - * @return void |
|
131 | + * @return string |
|
132 | 132 | */ |
133 | 133 | function __construct() |
134 | 134 | { |
@@ -116,7 +116,7 @@ |
||
116 | 116 | * In this case, the column type is retrieved according to argument |
117 | 117 | * value type (using the PHP function is_numeric). |
118 | 118 | * |
119 | - * @return type string |
|
119 | + * @return string string |
|
120 | 120 | */ |
121 | 121 | function getType() |
122 | 122 | { |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | function __construct($name, $value, $operation) |
27 | 27 | { |
28 | 28 | $operationList = array('in' => 1, 'notin' => 1, 'not_in' => 1, 'between' => 1); |
29 | - if(isset($value) && isset($operationList[$operation]) && !is_array($value) && $value != '') |
|
29 | + if (isset($value) && isset($operationList[$operation]) && !is_array($value) && $value != '') |
|
30 | 30 | { |
31 | 31 | $value = str_replace(' ', '', $value); |
32 | 32 | $value = str_replace('\'', '', $value); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | function createConditionValue() |
44 | 44 | { |
45 | - if(!isset($this->value)) |
|
45 | + if (!isset($this->value)) |
|
46 | 46 | { |
47 | 47 | return; |
48 | 48 | } |
@@ -50,56 +50,56 @@ discard block |
||
50 | 50 | $operation = $this->operation; |
51 | 51 | $value = $this->value; |
52 | 52 | |
53 | - switch($operation) |
|
53 | + switch ($operation) |
|
54 | 54 | { |
55 | 55 | case 'like_prefix' : |
56 | - if(defined('__CUBRID_VERSION__') && __CUBRID_VERSION__ >= '8.4.1') |
|
56 | + if (defined('__CUBRID_VERSION__') && __CUBRID_VERSION__ >= '8.4.1') |
|
57 | 57 | { |
58 | - $this->value = '^' . str_replace('%', '(.*)', preg_quote($value)); |
|
58 | + $this->value = '^'.str_replace('%', '(.*)', preg_quote($value)); |
|
59 | 59 | } |
60 | 60 | else |
61 | 61 | { |
62 | - $this->value = $value . '%'; |
|
62 | + $this->value = $value.'%'; |
|
63 | 63 | } |
64 | 64 | break; |
65 | 65 | case 'like_tail' : |
66 | - if(defined('__CUBRID_VERSION__') && __CUBRID_VERSION__ >= '8.4.1') |
|
66 | + if (defined('__CUBRID_VERSION__') && __CUBRID_VERSION__ >= '8.4.1') |
|
67 | 67 | { |
68 | - $this->value = str_replace('%', '(.*)', preg_quote($value)) . '$'; |
|
68 | + $this->value = str_replace('%', '(.*)', preg_quote($value)).'$'; |
|
69 | 69 | } |
70 | 70 | else |
71 | 71 | { |
72 | - $this->value = '%' . $value; |
|
72 | + $this->value = '%'.$value; |
|
73 | 73 | } |
74 | 74 | break; |
75 | 75 | case 'like' : |
76 | - if(defined('__CUBRID_VERSION__') && __CUBRID_VERSION__ >= '8.4.1') |
|
76 | + if (defined('__CUBRID_VERSION__') && __CUBRID_VERSION__ >= '8.4.1') |
|
77 | 77 | { |
78 | 78 | $this->value = str_replace('%', '(.*)', preg_quote($value)); |
79 | 79 | } |
80 | 80 | else |
81 | 81 | { |
82 | - $this->value = '%' . $value . '%'; |
|
82 | + $this->value = '%'.$value.'%'; |
|
83 | 83 | } |
84 | 84 | break; |
85 | 85 | case 'notlike' : |
86 | - $this->value = '%' . $value . '%'; |
|
86 | + $this->value = '%'.$value.'%'; |
|
87 | 87 | break; |
88 | 88 | case 'notlike_prefix' : |
89 | - $this->value = $value . '%'; |
|
89 | + $this->value = $value.'%'; |
|
90 | 90 | break; |
91 | 91 | case 'notlike_tail' : |
92 | - $this->value = '%' . $value; |
|
92 | + $this->value = '%'.$value; |
|
93 | 93 | break; |
94 | 94 | case 'in': |
95 | - if(!is_array($value)) |
|
95 | + if (!is_array($value)) |
|
96 | 96 | { |
97 | 97 | $this->value = array($value); |
98 | 98 | } |
99 | 99 | break; |
100 | 100 | case 'notin': |
101 | 101 | case 'not_in': |
102 | - if(!is_array($value)) |
|
102 | + if (!is_array($value)) |
|
103 | 103 | { |
104 | 104 | $this->value = array($value); |
105 | 105 | } |
@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | */ |
121 | 121 | function getType() |
122 | 122 | { |
123 | - if($this->type) |
|
123 | + if ($this->type) |
|
124 | 124 | { |
125 | 125 | return $this->type; |
126 | 126 | } |
127 | - else if(!is_numeric($this->value)) |
|
127 | + else if (!is_numeric($this->value)) |
|
128 | 128 | { |
129 | 129 | return 'varchar'; |
130 | 130 | } |
@@ -136,11 +136,11 @@ discard block |
||
136 | 136 | |
137 | 137 | function setColumnType($column_type) |
138 | 138 | { |
139 | - if(!isset($this->value)) |
|
139 | + if (!isset($this->value)) |
|
140 | 140 | { |
141 | 141 | return; |
142 | 142 | } |
143 | - if($column_type === '') |
|
143 | + if ($column_type === '') |
|
144 | 144 | { |
145 | 145 | return; |
146 | 146 | } |
@@ -56,8 +56,7 @@ discard block |
||
56 | 56 | if(defined('__CUBRID_VERSION__') && __CUBRID_VERSION__ >= '8.4.1') |
57 | 57 | { |
58 | 58 | $this->value = '^' . str_replace('%', '(.*)', preg_quote($value)); |
59 | - } |
|
60 | - else |
|
59 | + } else |
|
61 | 60 | { |
62 | 61 | $this->value = $value . '%'; |
63 | 62 | } |
@@ -66,8 +65,7 @@ discard block |
||
66 | 65 | if(defined('__CUBRID_VERSION__') && __CUBRID_VERSION__ >= '8.4.1') |
67 | 66 | { |
68 | 67 | $this->value = str_replace('%', '(.*)', preg_quote($value)) . '$'; |
69 | - } |
|
70 | - else |
|
68 | + } else |
|
71 | 69 | { |
72 | 70 | $this->value = '%' . $value; |
73 | 71 | } |
@@ -76,8 +74,7 @@ discard block |
||
76 | 74 | if(defined('__CUBRID_VERSION__') && __CUBRID_VERSION__ >= '8.4.1') |
77 | 75 | { |
78 | 76 | $this->value = str_replace('%', '(.*)', preg_quote($value)); |
79 | - } |
|
80 | - else |
|
77 | + } else |
|
81 | 78 | { |
82 | 79 | $this->value = '%' . $value . '%'; |
83 | 80 | } |
@@ -123,12 +120,10 @@ discard block |
||
123 | 120 | if($this->type) |
124 | 121 | { |
125 | 122 | return $this->type; |
126 | - } |
|
127 | - else if(!is_numeric($this->value)) |
|
123 | + } else if(!is_numeric($this->value)) |
|
128 | 124 | { |
129 | 125 | return 'varchar'; |
130 | - } |
|
131 | - else |
|
126 | + } else |
|
132 | 127 | { |
133 | 128 | return ''; |
134 | 129 | } |
@@ -28,7 +28,7 @@ |
||
28 | 28 | * |
29 | 29 | * @param object $query XML object obtained after reading the XML Query file |
30 | 30 | * @param bool $isSubQuery |
31 | - * @return void |
|
31 | + * @return string |
|
32 | 32 | */ |
33 | 33 | function __construct($query = NULL, $isSubQuery = FALSE) |
34 | 34 | { |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | */ |
33 | 33 | function __construct($query = NULL, $isSubQuery = FALSE) |
34 | 34 | { |
35 | - if($query) |
|
35 | + if ($query) |
|
36 | 36 | { |
37 | 37 | $this->queryTag = new QueryTag($query, $isSubQuery); |
38 | 38 | } |
@@ -54,17 +54,17 @@ discard block |
||
54 | 54 | $module = ''; |
55 | 55 | |
56 | 56 | $id_args = explode('.', $query_id); |
57 | - if(count($id_args) == 2) |
|
57 | + if (count($id_args) == 2) |
|
58 | 58 | { |
59 | 59 | $target = 'modules'; |
60 | 60 | $module = $id_args[0]; |
61 | 61 | $id = $id_args[1]; |
62 | 62 | } |
63 | - else if(count($id_args) == 3) |
|
63 | + else if (count($id_args) == 3) |
|
64 | 64 | { |
65 | 65 | $target = $id_args[0]; |
66 | 66 | $targetList = array('modules' => 1, 'addons' => 1, 'widgets' => 1); |
67 | - if(!isset($targetList[$target])) |
|
67 | + if (!isset($targetList[$target])) |
|
68 | 68 | { |
69 | 69 | return; |
70 | 70 | } |
@@ -74,33 +74,33 @@ discard block |
||
74 | 74 | |
75 | 75 | // get column properties from the table |
76 | 76 | $table_file = sprintf('%s%s/%s/schemas/%s.xml', _XE_PATH_, 'modules', $module, $table_name); |
77 | - if(!file_exists($table_file)) |
|
77 | + if (!file_exists($table_file)) |
|
78 | 78 | { |
79 | - $searched_list = FileHandler::readDir(_XE_PATH_ . 'modules'); |
|
79 | + $searched_list = FileHandler::readDir(_XE_PATH_.'modules'); |
|
80 | 80 | $searched_count = count($searched_list); |
81 | - for($i = 0; $i < $searched_count; $i++) |
|
81 | + for ($i = 0; $i < $searched_count; $i++) |
|
82 | 82 | { |
83 | 83 | $table_file = sprintf('%s%s/%s/schemas/%s.xml', _XE_PATH_, 'modules', $searched_list[$i], $table_name); |
84 | - if(file_exists($table_file)) |
|
84 | + if (file_exists($table_file)) |
|
85 | 85 | { |
86 | 86 | break; |
87 | 87 | } |
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
91 | - if(file_exists($table_file)) |
|
91 | + if (file_exists($table_file)) |
|
92 | 92 | { |
93 | 93 | $table_xml = FileHandler::readFile($table_file); |
94 | 94 | $xml_parser = new XmlParser(); |
95 | 95 | $table_obj = $xml_parser->parse($table_xml); |
96 | - if($table_obj->table) |
|
96 | + if ($table_obj->table) |
|
97 | 97 | { |
98 | - if(isset($table_obj->table->column) && !is_array($table_obj->table->column)) |
|
98 | + if (isset($table_obj->table->column) && !is_array($table_obj->table->column)) |
|
99 | 99 | { |
100 | 100 | $table_obj->table->column = array($table_obj->table->column); |
101 | 101 | } |
102 | 102 | |
103 | - foreach($table_obj->table->column as $k => $v) |
|
103 | + foreach ($table_obj->table->column as $k => $v) |
|
104 | 104 | { |
105 | 105 | $column_type[$v->attrs->name] = $v->attrs->type; |
106 | 106 | } |
@@ -59,8 +59,7 @@ |
||
59 | 59 | $target = 'modules'; |
60 | 60 | $module = $id_args[0]; |
61 | 61 | $id = $id_args[1]; |
62 | - } |
|
63 | - else if(count($id_args) == 3) |
|
62 | + } else if(count($id_args) == 3) |
|
64 | 63 | { |
65 | 64 | $target = $id_args[0]; |
66 | 65 | $targetList = array('modules' => 1, 'addons' => 1, 'widgets' => 1); |
@@ -169,6 +169,9 @@ |
||
169 | 169 | return $this->query->attrs->action; |
170 | 170 | } |
171 | 171 | |
172 | + /** |
|
173 | + * @param TablesTag $tables |
|
174 | + */ |
|
172 | 175 | function setTableColumnTypes($tables) |
173 | 176 | { |
174 | 177 | $query_id = $this->getQueryId(); |
@@ -126,11 +126,11 @@ discard block |
||
126 | 126 | $this->priority = $query->attrs->priority; |
127 | 127 | $this->query = $query; |
128 | 128 | $this->isSubQuery = $isSubQuery; |
129 | - if($this->isSubQuery) |
|
129 | + if ($this->isSubQuery) |
|
130 | 130 | { |
131 | 131 | $this->action = 'select'; |
132 | 132 | } |
133 | - if($query->attrs->alias) |
|
133 | + if ($query->attrs->alias) |
|
134 | 134 | { |
135 | 135 | $dbParser = DB::getParser(); |
136 | 136 | $this->alias = $dbParser->escape($query->attrs->alias); |
@@ -172,13 +172,13 @@ discard block |
||
172 | 172 | function setTableColumnTypes($tables) |
173 | 173 | { |
174 | 174 | $query_id = $this->getQueryId(); |
175 | - if(!isset($this->column_type[$query_id])) |
|
175 | + if (!isset($this->column_type[$query_id])) |
|
176 | 176 | { |
177 | 177 | $table_tags = $tables->getTables(); |
178 | 178 | $column_type = array(); |
179 | - foreach($table_tags as $table_tag) |
|
179 | + foreach ($table_tags as $table_tag) |
|
180 | 180 | { |
181 | - if(is_a($table_tag, 'TableTag')) |
|
181 | + if (is_a($table_tag, 'TableTag')) |
|
182 | 182 | { |
183 | 183 | $table_name = $table_tag->getTableName(); |
184 | 184 | $table_alias = $table_tag->getTableAlias(); |
@@ -192,19 +192,19 @@ discard block |
||
192 | 192 | |
193 | 193 | function getColumns() |
194 | 194 | { |
195 | - if($this->action == 'select') |
|
195 | + if ($this->action == 'select') |
|
196 | 196 | { |
197 | 197 | return $this->columns = new SelectColumnsTag($this->query->columns); |
198 | 198 | } |
199 | - else if($this->action == 'insert' || $this->action == 'insert-select') |
|
199 | + else if ($this->action == 'insert' || $this->action == 'insert-select') |
|
200 | 200 | { |
201 | 201 | return $this->columns = new InsertColumnsTag($this->query->columns->column); |
202 | 202 | } |
203 | - else if($this->action == 'update') |
|
203 | + else if ($this->action == 'update') |
|
204 | 204 | { |
205 | 205 | return $this->columns = new UpdateColumnsTag($this->query->columns->column); |
206 | 206 | } |
207 | - else if($this->action == 'delete') |
|
207 | + else if ($this->action == 'delete') |
|
208 | 208 | { |
209 | 209 | return $this->columns = null; |
210 | 210 | } |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | |
213 | 213 | function getPrebuff() |
214 | 214 | { |
215 | - if($this->isSubQuery) |
|
215 | + if ($this->isSubQuery) |
|
216 | 216 | { |
217 | 217 | return; |
218 | 218 | } |
@@ -220,20 +220,20 @@ discard block |
||
220 | 220 | $arguments = $this->getArguments(); |
221 | 221 | |
222 | 222 | $prebuff = ''; |
223 | - foreach($arguments as $argument) |
|
223 | + foreach ($arguments as $argument) |
|
224 | 224 | { |
225 | - if(isset($argument)) |
|
225 | + if (isset($argument)) |
|
226 | 226 | { |
227 | 227 | $arg_name = $argument->getArgumentName(); |
228 | - if($arg_name) |
|
228 | + if ($arg_name) |
|
229 | 229 | { |
230 | 230 | unset($column_type); |
231 | 231 | $prebuff .= $argument->toString(); |
232 | 232 | |
233 | 233 | $table_alias = $argument->getTableName(); |
234 | - if(isset($table_alias)) |
|
234 | + if (isset($table_alias)) |
|
235 | 235 | { |
236 | - if(isset($this->column_type[$this->getQueryId()][$table_alias][$argument->getColumnName()])) |
|
236 | + if (isset($this->column_type[$this->getQueryId()][$table_alias][$argument->getColumnName()])) |
|
237 | 237 | { |
238 | 238 | $column_type = $this->column_type[$this->getQueryId()][$table_alias][$argument->getColumnName()]; |
239 | 239 | } |
@@ -242,18 +242,18 @@ discard block |
||
242 | 242 | { |
243 | 243 | $current_tables = $this->column_type[$this->getQueryId()]; |
244 | 244 | $column_name = $argument->getColumnName(); |
245 | - foreach($current_tables as $current_table) |
|
245 | + foreach ($current_tables as $current_table) |
|
246 | 246 | { |
247 | - if(isset($current_table[$column_name])) |
|
247 | + if (isset($current_table[$column_name])) |
|
248 | 248 | { |
249 | 249 | $column_type = $current_table[$column_name]; |
250 | 250 | } |
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
254 | - if(isset($column_type)) |
|
254 | + if (isset($column_type)) |
|
255 | 255 | { |
256 | - $prebuff .= sprintf('if(${\'%s_argument\'} !== null) ${\'%s_argument\'}->setColumnType(\'%s\');' . "\n" |
|
256 | + $prebuff .= sprintf('if(${\'%s_argument\'} !== null) ${\'%s_argument\'}->setColumnType(\'%s\');'."\n" |
|
257 | 257 | , $arg_name |
258 | 258 | , $arg_name |
259 | 259 | , $column_type); |
@@ -269,43 +269,43 @@ discard block |
||
269 | 269 | function getBuff() |
270 | 270 | { |
271 | 271 | $buff = ''; |
272 | - if($this->isSubQuery) |
|
272 | + if ($this->isSubQuery) |
|
273 | 273 | { |
274 | 274 | $buff = 'new Subquery('; |
275 | - $buff .= "'" . $this->alias . '\', '; |
|
276 | - $buff .= ($this->columns ? $this->columns->toString() : 'null' ) . ', ' . PHP_EOL; |
|
277 | - $buff .= $this->tables->toString() . ',' . PHP_EOL; |
|
278 | - $buff .= $this->conditions->toString() . ',' . PHP_EOL; |
|
279 | - $buff .= $this->groups->toString() . ',' . PHP_EOL; |
|
280 | - $buff .= $this->navigation->getOrderByString() . ',' . PHP_EOL; |
|
275 | + $buff .= "'".$this->alias.'\', '; |
|
276 | + $buff .= ($this->columns ? $this->columns->toString() : 'null').', '.PHP_EOL; |
|
277 | + $buff .= $this->tables->toString().','.PHP_EOL; |
|
278 | + $buff .= $this->conditions->toString().','.PHP_EOL; |
|
279 | + $buff .= $this->groups->toString().','.PHP_EOL; |
|
280 | + $buff .= $this->navigation->getOrderByString().','.PHP_EOL; |
|
281 | 281 | $limit = $this->navigation->getLimitString(); |
282 | - $buff .= $limit ? $limit : 'null' . PHP_EOL; |
|
283 | - $buff .= $this->join_type ? "'" . $this->join_type . "'" : ''; |
|
282 | + $buff .= $limit ? $limit : 'null'.PHP_EOL; |
|
283 | + $buff .= $this->join_type ? "'".$this->join_type."'" : ''; |
|
284 | 284 | $buff .= ')'; |
285 | 285 | |
286 | 286 | $this->buff = $buff; |
287 | 287 | return $this->buff; |
288 | 288 | } |
289 | 289 | |
290 | - $buff .= '$query = new Query();' . PHP_EOL; |
|
290 | + $buff .= '$query = new Query();'.PHP_EOL; |
|
291 | 291 | $buff .= sprintf('$query->setQueryId("%s");%s', $this->query_id, "\n"); |
292 | 292 | $buff .= sprintf('$query->setAction("%s");%s', $this->action, "\n"); |
293 | 293 | $buff .= sprintf('$query->setPriority("%s");%s', $this->priority, "\n"); |
294 | 294 | $buff .= $this->preBuff; |
295 | - if($this->columns) |
|
295 | + if ($this->columns) |
|
296 | 296 | { |
297 | - $buff .= '$query->setColumns(' . $this->columns->toString() . ');' . PHP_EOL; |
|
297 | + $buff .= '$query->setColumns('.$this->columns->toString().');'.PHP_EOL; |
|
298 | 298 | } |
299 | 299 | |
300 | - $buff .= '$query->setTables(' . $this->tables->toString() . ');' . PHP_EOL; |
|
301 | - if($this->action == 'insert-select') |
|
300 | + $buff .= '$query->setTables('.$this->tables->toString().');'.PHP_EOL; |
|
301 | + if ($this->action == 'insert-select') |
|
302 | 302 | { |
303 | - $buff .= '$query->setSubquery(' . $this->subquery->toString() . ');' . PHP_EOL; |
|
303 | + $buff .= '$query->setSubquery('.$this->subquery->toString().');'.PHP_EOL; |
|
304 | 304 | } |
305 | - $buff .= '$query->setConditions(' . $this->conditions->toString() . ');' . PHP_EOL; |
|
306 | - $buff .= '$query->setGroups(' . $this->groups->toString() . ');' . PHP_EOL; |
|
307 | - $buff .= '$query->setOrder(' . $this->navigation->getOrderByString() . ');' . PHP_EOL; |
|
308 | - $buff .= '$query->setLimit(' . $this->navigation->getLimitString() . ');' . PHP_EOL; |
|
305 | + $buff .= '$query->setConditions('.$this->conditions->toString().');'.PHP_EOL; |
|
306 | + $buff .= '$query->setGroups('.$this->groups->toString().');'.PHP_EOL; |
|
307 | + $buff .= '$query->setOrder('.$this->navigation->getOrderByString().');'.PHP_EOL; |
|
308 | + $buff .= '$query->setLimit('.$this->navigation->getLimitString().');'.PHP_EOL; |
|
309 | 309 | |
310 | 310 | $this->buff = $buff; |
311 | 311 | return $this->buff; |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | |
314 | 314 | function getTables() |
315 | 315 | { |
316 | - if($this->query->index_hint && ($this->query->index_hint->attrs->for == 'ALL' || Context::getDBType() == strtolower($this->query->index_hint->attrs->for))) |
|
316 | + if ($this->query->index_hint && ($this->query->index_hint->attrs->for == 'ALL' || Context::getDBType() == strtolower($this->query->index_hint->attrs->for))) |
|
317 | 317 | { |
318 | 318 | return $this->tables = new TablesTag($this->query->tables, $this->query->index_hint); |
319 | 319 | } |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | |
326 | 326 | function getSubquery() |
327 | 327 | { |
328 | - if($this->query->query) |
|
328 | + if ($this->query->query) |
|
329 | 329 | { |
330 | 330 | $this->subquery = new QueryTag($this->query->query, true); |
331 | 331 | } |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | |
339 | 339 | function getGroups() |
340 | 340 | { |
341 | - if($this->query->groups) |
|
341 | + if ($this->query->groups) |
|
342 | 342 | { |
343 | 343 | return $this->groups = new GroupsTag($this->query->groups->group); |
344 | 344 | } |
@@ -376,11 +376,11 @@ discard block |
||
376 | 376 | function getArguments() |
377 | 377 | { |
378 | 378 | $arguments = array(); |
379 | - if($this->columns) |
|
379 | + if ($this->columns) |
|
380 | 380 | { |
381 | 381 | $arguments = array_merge($arguments, $this->columns->getArguments()); |
382 | 382 | } |
383 | - if($this->action == 'insert-select') |
|
383 | + if ($this->action == 'insert-select') |
|
384 | 384 | { |
385 | 385 | $arguments = array_merge($arguments, $this->subquery->getArguments()); |
386 | 386 | } |
@@ -195,16 +195,13 @@ discard block |
||
195 | 195 | if($this->action == 'select') |
196 | 196 | { |
197 | 197 | return $this->columns = new SelectColumnsTag($this->query->columns); |
198 | - } |
|
199 | - else if($this->action == 'insert' || $this->action == 'insert-select') |
|
198 | + } else if($this->action == 'insert' || $this->action == 'insert-select') |
|
200 | 199 | { |
201 | 200 | return $this->columns = new InsertColumnsTag($this->query->columns->column); |
202 | - } |
|
203 | - else if($this->action == 'update') |
|
201 | + } else if($this->action == 'update') |
|
204 | 202 | { |
205 | 203 | return $this->columns = new UpdateColumnsTag($this->query->columns->column); |
206 | - } |
|
207 | - else if($this->action == 'delete') |
|
204 | + } else if($this->action == 'delete') |
|
208 | 205 | { |
209 | 206 | return $this->columns = null; |
210 | 207 | } |
@@ -237,8 +234,7 @@ discard block |
||
237 | 234 | { |
238 | 235 | $column_type = $this->column_type[$this->getQueryId()][$table_alias][$argument->getColumnName()]; |
239 | 236 | } |
240 | - } |
|
241 | - else |
|
237 | + } else |
|
242 | 238 | { |
243 | 239 | $current_tables = $this->column_type[$this->getQueryId()]; |
244 | 240 | $column_name = $argument->getColumnName(); |
@@ -316,8 +312,7 @@ discard block |
||
316 | 312 | if($this->query->index_hint && ($this->query->index_hint->attrs->for == 'ALL' || Context::getDBType() == strtolower($this->query->index_hint->attrs->for))) |
317 | 313 | { |
318 | 314 | return $this->tables = new TablesTag($this->query->tables, $this->query->index_hint); |
319 | - } |
|
320 | - else |
|
315 | + } else |
|
321 | 316 | { |
322 | 317 | return $this->tables = new TablesTag($this->query->tables); |
323 | 318 | } |
@@ -341,8 +336,7 @@ discard block |
||
341 | 336 | if($this->query->groups) |
342 | 337 | { |
343 | 338 | return $this->groups = new GroupsTag($this->query->groups->group); |
344 | - } |
|
345 | - else |
|
339 | + } else |
|
346 | 340 | { |
347 | 341 | return $this->groups = new GroupsTag(NULL); |
348 | 342 | } |