@@ -191,8 +191,7 @@ discard block |
||
191 | 191 | default: |
192 | 192 | if ($this->isAlphaNum($this->b)) { |
193 | 193 | $this->action(1); |
194 | - } |
|
195 | - else { |
|
194 | + } else { |
|
196 | 195 | $this->action(2); |
197 | 196 | } |
198 | 197 | } |
@@ -224,8 +223,7 @@ discard block |
||
224 | 223 | default: |
225 | 224 | if ($this->isAlphaNum($this->a)) { |
226 | 225 | $this->action(1); |
227 | - } |
|
228 | - else { |
|
226 | + } else { |
|
229 | 227 | $this->action(3); |
230 | 228 | } |
231 | 229 | } |
@@ -47,29 +47,29 @@ discard block |
||
47 | 47 | namespace Prado\Web\Javascripts; |
48 | 48 | |
49 | 49 | class JSMin { |
50 | - const ORD_LF = 10; |
|
51 | - const ORD_SPACE = 32; |
|
50 | + const ORD_LF=10; |
|
51 | + const ORD_SPACE=32; |
|
52 | 52 | |
53 | - protected $a = ''; |
|
54 | - protected $b = ''; |
|
55 | - protected $input = ''; |
|
56 | - protected $inputIndex = 0; |
|
57 | - protected $inputLength = 0; |
|
58 | - protected $lookAhead = null; |
|
59 | - protected $output = ''; |
|
53 | + protected $a=''; |
|
54 | + protected $b=''; |
|
55 | + protected $input=''; |
|
56 | + protected $inputIndex=0; |
|
57 | + protected $inputLength=0; |
|
58 | + protected $lookAhead=null; |
|
59 | + protected $output=''; |
|
60 | 60 | |
61 | 61 | // -- Public Static Methods -------------------------------------------------- |
62 | 62 | |
63 | 63 | public static function minify($js) { |
64 | - $jsmin = new JSMin($js); |
|
64 | + $jsmin=new JSMin($js); |
|
65 | 65 | return $jsmin->min(); |
66 | 66 | } |
67 | 67 | |
68 | 68 | // -- Public Instance Methods ------------------------------------------------ |
69 | 69 | |
70 | 70 | public function __construct($input) { |
71 | - $this->input = str_replace("\r\n", "\n", $input); |
|
72 | - $this->inputLength = strlen($this->input); |
|
71 | + $this->input=str_replace("\r\n", "\n", $input); |
|
72 | + $this->inputLength=strlen($this->input); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | // -- Protected Instance Methods --------------------------------------------- |
@@ -77,80 +77,80 @@ discard block |
||
77 | 77 | protected function action($d) { |
78 | 78 | switch($d) { |
79 | 79 | case 1: |
80 | - $this->output .= $this->a; |
|
80 | + $this->output.=$this->a; |
|
81 | 81 | |
82 | 82 | case 2: |
83 | - $this->a = $this->b; |
|
83 | + $this->a=$this->b; |
|
84 | 84 | |
85 | - if ($this->a === "'" || $this->a === '"') { |
|
86 | - for (;;) { |
|
87 | - $this->output .= $this->a; |
|
88 | - $this->a = $this->get(); |
|
85 | + if($this->a==="'" || $this->a==='"') { |
|
86 | + for(;;) { |
|
87 | + $this->output.=$this->a; |
|
88 | + $this->a=$this->get(); |
|
89 | 89 | |
90 | - if ($this->a === $this->b) { |
|
90 | + if($this->a===$this->b) { |
|
91 | 91 | break; |
92 | 92 | } |
93 | 93 | |
94 | - if (ord($this->a) <= self::ORD_LF) { |
|
94 | + if(ord($this->a) <= self::ORD_LF) { |
|
95 | 95 | throw new JSMinException('Unterminated string literal.'); |
96 | 96 | } |
97 | 97 | |
98 | - if ($this->a === '\\') { |
|
99 | - $this->output .= $this->a; |
|
100 | - $this->a = $this->get(); |
|
98 | + if($this->a==='\\') { |
|
99 | + $this->output.=$this->a; |
|
100 | + $this->a=$this->get(); |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
105 | 105 | case 3: |
106 | - $this->b = $this->next(); |
|
106 | + $this->b=$this->next(); |
|
107 | 107 | |
108 | - if ($this->b === '/' && ( |
|
109 | - $this->a === '(' || $this->a === ',' || $this->a === '=' || |
|
110 | - $this->a === ':' || $this->a === '[' || $this->a === '!' || |
|
111 | - $this->a === '&' || $this->a === '|' || $this->a === '?')) { |
|
108 | + if($this->b==='/' && ( |
|
109 | + $this->a==='(' || $this->a===',' || $this->a==='=' || |
|
110 | + $this->a===':' || $this->a==='[' || $this->a==='!' || |
|
111 | + $this->a==='&' || $this->a==='|' || $this->a==='?')) { |
|
112 | 112 | |
113 | - $this->output .= $this->a . $this->b; |
|
113 | + $this->output.=$this->a.$this->b; |
|
114 | 114 | |
115 | - for (;;) { |
|
116 | - $this->a = $this->get(); |
|
115 | + for(;;) { |
|
116 | + $this->a=$this->get(); |
|
117 | 117 | |
118 | - if ($this->a === '/') { |
|
118 | + if($this->a==='/') { |
|
119 | 119 | break; |
120 | - } elseif ($this->a === '\\') { |
|
121 | - $this->output .= $this->a; |
|
122 | - $this->a = $this->get(); |
|
123 | - } elseif (ord($this->a) <= self::ORD_LF) { |
|
120 | + } elseif($this->a==='\\') { |
|
121 | + $this->output.=$this->a; |
|
122 | + $this->a=$this->get(); |
|
123 | + } elseif(ord($this->a) <= self::ORD_LF) { |
|
124 | 124 | throw new JSMinException('Unterminated regular expression '. |
125 | 125 | 'literal.'); |
126 | 126 | } |
127 | 127 | |
128 | - $this->output .= $this->a; |
|
128 | + $this->output.=$this->a; |
|
129 | 129 | } |
130 | 130 | |
131 | - $this->b = $this->next(); |
|
131 | + $this->b=$this->next(); |
|
132 | 132 | } |
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
136 | 136 | protected function get() { |
137 | - $c = $this->lookAhead; |
|
138 | - $this->lookAhead = null; |
|
137 | + $c=$this->lookAhead; |
|
138 | + $this->lookAhead=null; |
|
139 | 139 | |
140 | - if ($c === null) { |
|
141 | - if ($this->inputIndex < $this->inputLength) { |
|
142 | - $c = $this->input[$this->inputIndex]; |
|
143 | - $this->inputIndex += 1; |
|
140 | + if($c===null) { |
|
141 | + if($this->inputIndex < $this->inputLength) { |
|
142 | + $c=$this->input[$this->inputIndex]; |
|
143 | + $this->inputIndex+=1; |
|
144 | 144 | } else { |
145 | - $c = null; |
|
145 | + $c=null; |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
149 | - if ($c === "\r") { |
|
149 | + if($c==="\r") { |
|
150 | 150 | return "\n"; |
151 | 151 | } |
152 | 152 | |
153 | - if ($c === null || $c === "\n" || ord($c) >= self::ORD_SPACE) { |
|
153 | + if($c===null || $c==="\n" || ord($c) >= self::ORD_SPACE) { |
|
154 | 154 | return $c; |
155 | 155 | } |
156 | 156 | |
@@ -158,17 +158,17 @@ discard block |
||
158 | 158 | } |
159 | 159 | |
160 | 160 | protected function isAlphaNum($c) { |
161 | - return ord($c) > 126 || $c === '\\' || preg_match('/^[\w\$]$/', $c) === 1; |
|
161 | + return ord($c) > 126 || $c==='\\' || preg_match('/^[\w\$]$/', $c)===1; |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | protected function min() { |
165 | - $this->a = "\n"; |
|
165 | + $this->a="\n"; |
|
166 | 166 | $this->action(3); |
167 | 167 | |
168 | - while ($this->a !== null) { |
|
169 | - switch ($this->a) { |
|
168 | + while($this->a!==null) { |
|
169 | + switch($this->a) { |
|
170 | 170 | case ' ': |
171 | - if ($this->isAlphaNum($this->b)) { |
|
171 | + if($this->isAlphaNum($this->b)) { |
|
172 | 172 | $this->action(1); |
173 | 173 | } else { |
174 | 174 | $this->action(2); |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | break; |
177 | 177 | |
178 | 178 | case "\n": |
179 | - switch ($this->b) { |
|
179 | + switch($this->b) { |
|
180 | 180 | case '{': |
181 | 181 | case '[': |
182 | 182 | case '(': |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | break; |
191 | 191 | |
192 | 192 | default: |
193 | - if ($this->isAlphaNum($this->b)) { |
|
193 | + if($this->isAlphaNum($this->b)) { |
|
194 | 194 | $this->action(1); |
195 | 195 | } |
196 | 196 | else { |
@@ -200,9 +200,9 @@ discard block |
||
200 | 200 | break; |
201 | 201 | |
202 | 202 | default: |
203 | - switch ($this->b) { |
|
203 | + switch($this->b) { |
|
204 | 204 | case ' ': |
205 | - if ($this->isAlphaNum($this->a)) { |
|
205 | + if($this->isAlphaNum($this->a)) { |
|
206 | 206 | $this->action(1); |
207 | 207 | break; |
208 | 208 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | break; |
212 | 212 | |
213 | 213 | case "\n": |
214 | - switch ($this->a) { |
|
214 | + switch($this->a) { |
|
215 | 215 | case '}': |
216 | 216 | case ']': |
217 | 217 | case ')': |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | break; |
224 | 224 | |
225 | 225 | default: |
226 | - if ($this->isAlphaNum($this->a)) { |
|
226 | + if($this->isAlphaNum($this->a)) { |
|
227 | 227 | $this->action(1); |
228 | 228 | } |
229 | 229 | else { |
@@ -243,15 +243,15 @@ discard block |
||
243 | 243 | } |
244 | 244 | |
245 | 245 | protected function next() { |
246 | - $c = $this->get(); |
|
246 | + $c=$this->get(); |
|
247 | 247 | |
248 | - if ($c === '/') { |
|
248 | + if($c==='/') { |
|
249 | 249 | switch($this->peek()) { |
250 | 250 | case '/': |
251 | - for (;;) { |
|
252 | - $c = $this->get(); |
|
251 | + for(;;) { |
|
252 | + $c=$this->get(); |
|
253 | 253 | |
254 | - if (ord($c) <= self::ORD_LF) { |
|
254 | + if(ord($c) <= self::ORD_LF) { |
|
255 | 255 | return $c; |
256 | 256 | } |
257 | 257 | } |
@@ -259,10 +259,10 @@ discard block |
||
259 | 259 | case '*': |
260 | 260 | $this->get(); |
261 | 261 | |
262 | - for (;;) { |
|
262 | + for(;;) { |
|
263 | 263 | switch($this->get()) { |
264 | 264 | case '*': |
265 | - if ($this->peek() === '/') { |
|
265 | + if($this->peek()==='/') { |
|
266 | 266 | $this->get(); |
267 | 267 | return ' '; |
268 | 268 | } |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | } |
283 | 283 | |
284 | 284 | protected function peek() { |
285 | - $this->lookAhead = $this->get(); |
|
285 | + $this->lookAhead=$this->get(); |
|
286 | 286 | return $this->lookAhead; |
287 | 287 | } |
288 | 288 | } |
289 | 289 | \ No newline at end of file |
@@ -129,28 +129,24 @@ |
||
129 | 129 | { |
130 | 130 | $param->setData($data); |
131 | 131 | $this->_nextPageList = null; |
132 | - } |
|
133 | - else |
|
132 | + } else |
|
134 | 133 | { |
135 | 134 | $param->setData(array_slice($data, 0, $pageSize)); |
136 | 135 | $this->_nextPageList = array_slice($data, $pageSize-1,$total); |
137 | 136 | } |
138 | - } |
|
139 | - else |
|
137 | + } else |
|
140 | 138 | { |
141 | 139 | if($total <= $pageSize) |
142 | 140 | { |
143 | 141 | $this->_prevPageList = array_slice($data, 0, $total); |
144 | 142 | $param->setData(array()); |
145 | 143 | $this->_nextPageList = null; |
146 | - } |
|
147 | - else if($total <= $pageSize*2) |
|
144 | + } else if($total <= $pageSize*2) |
|
148 | 145 | { |
149 | 146 | $this->_prevPageList = array_slice($data, 0, $pageSize); |
150 | 147 | $param->setData(array_slice($data, $pageSize, $total)); |
151 | 148 | $this->_nextPageList = null; |
152 | - } |
|
153 | - else |
|
149 | + } else |
|
154 | 150 | { |
155 | 151 | $this->_prevPageList = array_slice($data, 0, $pageSize); |
156 | 152 | $param->setData(array_slice($data, $pageSize, $pageSize)); |
@@ -41,11 +41,11 @@ discard block |
||
41 | 41 | * @param mixed delegate for each data row retrieved. |
42 | 42 | * @param int number of page to fetch on initialization |
43 | 43 | */ |
44 | - public function __construct(IMappedStatement $statement,$parameter, $pageSize, $delegate=null, $page=0) |
|
44 | + public function __construct(IMappedStatement $statement, $parameter, $pageSize, $delegate=null, $page=0) |
|
45 | 45 | { |
46 | 46 | parent::__construct(); |
47 | 47 | parent::setCustomPaging(true); |
48 | - $this->initialize($statement,$parameter, $pageSize, $page); |
|
48 | + $this->initialize($statement, $parameter, $pageSize, $page); |
|
49 | 49 | $this->_delegate=$delegate; |
50 | 50 | } |
51 | 51 | |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | */ |
59 | 59 | protected function initialize($statement, $parameter, $pageSize, $page) |
60 | 60 | { |
61 | - $this->_statement = $statement; |
|
62 | - $this->_parameter = $parameter; |
|
61 | + $this->_statement=$statement; |
|
62 | + $this->_parameter=$parameter; |
|
63 | 63 | $this->setPageSize($pageSize); |
64 | 64 | $this->attachEventHandler('OnFetchData', array($this, 'fetchDataFromStatement')); |
65 | 65 | $this->gotoPage($page); |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | */ |
81 | 81 | protected function fetchDataFromStatement($sender, $param) |
82 | 82 | { |
83 | - $limit = $this->getOffsetAndLimit($param); |
|
84 | - $connection = $this->_statement->getManager()->getDbConnection(); |
|
85 | - $data = $this->_statement->executeQueryForList($connection, |
|
83 | + $limit=$this->getOffsetAndLimit($param); |
|
84 | + $connection=$this->_statement->getManager()->getDbConnection(); |
|
85 | + $data=$this->_statement->executeQueryForList($connection, |
|
86 | 86 | $this->_parameter, null, $limit[0], $limit[1], $this->_delegate); |
87 | 87 | $this->populateData($param, $data); |
88 | 88 | } |
@@ -112,49 +112,49 @@ discard block |
||
112 | 112 | */ |
113 | 113 | protected function populateData($param, $data) |
114 | 114 | { |
115 | - $total = $data instanceof TList ? $data->getCount() : count($data); |
|
116 | - $pageSize = $this->getPageSize(); |
|
115 | + $total=$data instanceof TList ? $data->getCount() : count($data); |
|
116 | + $pageSize=$this->getPageSize(); |
|
117 | 117 | if($total < 1) |
118 | 118 | { |
119 | 119 | $param->setData($data); |
120 | - $this->_prevPageList = null; |
|
121 | - $this->_nextPageList = null; |
|
120 | + $this->_prevPageList=null; |
|
121 | + $this->_nextPageList=null; |
|
122 | 122 | return; |
123 | 123 | } |
124 | 124 | |
125 | 125 | if($param->getNewPageIndex() < 1) |
126 | 126 | { |
127 | - $this->_prevPageList = null; |
|
127 | + $this->_prevPageList=null; |
|
128 | 128 | if($total <= $pageSize) |
129 | 129 | { |
130 | 130 | $param->setData($data); |
131 | - $this->_nextPageList = null; |
|
131 | + $this->_nextPageList=null; |
|
132 | 132 | } |
133 | 133 | else |
134 | 134 | { |
135 | 135 | $param->setData(array_slice($data, 0, $pageSize)); |
136 | - $this->_nextPageList = array_slice($data, $pageSize-1,$total); |
|
136 | + $this->_nextPageList=array_slice($data, $pageSize - 1, $total); |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | else |
140 | 140 | { |
141 | 141 | if($total <= $pageSize) |
142 | 142 | { |
143 | - $this->_prevPageList = array_slice($data, 0, $total); |
|
143 | + $this->_prevPageList=array_slice($data, 0, $total); |
|
144 | 144 | $param->setData(array()); |
145 | - $this->_nextPageList = null; |
|
145 | + $this->_nextPageList=null; |
|
146 | 146 | } |
147 | - else if($total <= $pageSize*2) |
|
147 | + else if($total <= $pageSize * 2) |
|
148 | 148 | { |
149 | - $this->_prevPageList = array_slice($data, 0, $pageSize); |
|
149 | + $this->_prevPageList=array_slice($data, 0, $pageSize); |
|
150 | 150 | $param->setData(array_slice($data, $pageSize, $total)); |
151 | - $this->_nextPageList = null; |
|
151 | + $this->_nextPageList=null; |
|
152 | 152 | } |
153 | 153 | else |
154 | 154 | { |
155 | - $this->_prevPageList = array_slice($data, 0, $pageSize); |
|
155 | + $this->_prevPageList=array_slice($data, 0, $pageSize); |
|
156 | 156 | $param->setData(array_slice($data, $pageSize, $pageSize)); |
157 | - $this->_nextPageList = array_slice($data, $pageSize*2, $total-$pageSize*2); |
|
157 | + $this->_nextPageList=array_slice($data, $pageSize * 2, $total - $pageSize * 2); |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | } |
@@ -166,9 +166,9 @@ discard block |
||
166 | 166 | */ |
167 | 167 | protected function getOffsetAndLimit($param) |
168 | 168 | { |
169 | - $index = $param->getNewPageIndex(); |
|
170 | - $pageSize = $this->getPageSize(); |
|
171 | - return $index < 1 ? array($index, $pageSize*2) : array(($index-1)*$pageSize, $pageSize*3); |
|
169 | + $index=$param->getNewPageIndex(); |
|
170 | + $pageSize=$this->getPageSize(); |
|
171 | + return $index < 1 ? array($index, $pageSize * 2) : array(($index - 1) * $pageSize, $pageSize * 3); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
@@ -416,8 +416,7 @@ |
||
416 | 416 | { |
417 | 417 | $useArgs = !is_array($parameters) && is_array($args); |
418 | 418 | return new TSqlCriteria($criteria,$useArgs ? $args : $parameters); |
419 | - } |
|
420 | - else if($criteria instanceof TSqlCriteria) |
|
419 | + } else if($criteria instanceof TSqlCriteria) |
|
421 | 420 | return $criteria; |
422 | 421 | else |
423 | 422 | throw new TDbException('dbtablegateway_invalid_criteria'); |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param string|TDbTableInfo table or view name or table information. |
91 | 91 | * @param TDbConnection database connection. |
92 | 92 | */ |
93 | - public function __construct($table,$connection) |
|
93 | + public function __construct($table, $connection) |
|
94 | 94 | { |
95 | 95 | $this->_connection=$connection; |
96 | 96 | if(is_string($table)) |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | protected function setTableInfo($tableInfo) |
108 | 108 | { |
109 | - $builder = $tableInfo->createCommandBuilder($this->getDbConnection()); |
|
109 | + $builder=$tableInfo->createCommandBuilder($this->getDbConnection()); |
|
110 | 110 | $this->initCommandBuilder($builder); |
111 | 111 | } |
112 | 112 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | */ |
117 | 117 | protected function setTableName($tableName) |
118 | 118 | { |
119 | - $meta = TDbMetaData::getInstance($this->getDbConnection()); |
|
119 | + $meta=TDbMetaData::getInstance($this->getDbConnection()); |
|
120 | 120 | $this->initCommandBuilder($meta->createCommandBuilder($tableName)); |
121 | 121 | } |
122 | 122 | |
@@ -135,9 +135,9 @@ discard block |
||
135 | 135 | */ |
136 | 136 | protected function initCommandBuilder($builder) |
137 | 137 | { |
138 | - $this->_command = new TDataGatewayCommand($builder); |
|
139 | - $this->_command->OnCreateCommand[] = array($this, 'onCreateCommand'); |
|
140 | - $this->_command->OnExecuteCommand[] = array($this, 'onExecuteCommand'); |
|
138 | + $this->_command=new TDataGatewayCommand($builder); |
|
139 | + $this->_command->OnCreateCommand[]=array($this, 'onCreateCommand'); |
|
140 | + $this->_command->OnExecuteCommand[]=array($this, 'onExecuteCommand'); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -191,8 +191,8 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function findBySql($sql, $parameters=array()) |
193 | 193 | { |
194 | - $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; |
|
195 | - $criteria = $this->getCriteria($sql,$parameters, $args); |
|
194 | + $args=func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
|
195 | + $criteria=$this->getCriteria($sql, $parameters, $args); |
|
196 | 196 | return $this->getCommand()->findBySql($criteria); |
197 | 197 | } |
198 | 198 | |
@@ -204,8 +204,8 @@ discard block |
||
204 | 204 | */ |
205 | 205 | public function findAllBySql($sql, $parameters=array()) |
206 | 206 | { |
207 | - $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; |
|
208 | - $criteria = $this->getCriteria($sql,$parameters, $args); |
|
207 | + $args=func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
|
208 | + $criteria=$this->getCriteria($sql, $parameters, $args); |
|
209 | 209 | return $this->getCommand()->findAllBySql($criteria); |
210 | 210 | } |
211 | 211 | |
@@ -228,8 +228,8 @@ discard block |
||
228 | 228 | */ |
229 | 229 | public function find($criteria, $parameters=array()) |
230 | 230 | { |
231 | - $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; |
|
232 | - $criteria = $this->getCriteria($criteria,$parameters, $args); |
|
231 | + $args=func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
|
232 | + $criteria=$this->getCriteria($criteria, $parameters, $args); |
|
233 | 233 | return $this->getCommand()->find($criteria); |
234 | 234 | } |
235 | 235 | |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | */ |
242 | 242 | public function findAll($criteria=null, $parameters=array()) |
243 | 243 | { |
244 | - $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; |
|
244 | + $args=func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
|
245 | 245 | if($criteria!==null) |
246 | - $criteria = $this->getCriteria($criteria,$parameters, $args); |
|
246 | + $criteria=$this->getCriteria($criteria, $parameters, $args); |
|
247 | 247 | return $this->getCommand()->findAll($criteria); |
248 | 248 | } |
249 | 249 | |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | public function findByPk($keys) |
263 | 263 | { |
264 | 264 | if(func_num_args() > 1) |
265 | - $keys = func_get_args(); |
|
265 | + $keys=func_get_args(); |
|
266 | 266 | return $this->getCommand()->findByPk($keys); |
267 | 267 | } |
268 | 268 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | public function findAllByPks($keys) |
287 | 287 | { |
288 | 288 | if(func_num_args() > 1) |
289 | - $keys = func_get_args(); |
|
289 | + $keys=func_get_args(); |
|
290 | 290 | return $this->getCommand()->findAllByPk($keys); |
291 | 291 | } |
292 | 292 | |
@@ -303,8 +303,8 @@ discard block |
||
303 | 303 | */ |
304 | 304 | public function deleteAll($criteria, $parameters=array()) |
305 | 305 | { |
306 | - $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; |
|
307 | - $criteria = $this->getCriteria($criteria,$parameters, $args); |
|
306 | + $args=func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
|
307 | + $criteria=$this->getCriteria($criteria, $parameters, $args); |
|
308 | 308 | return $this->getCommand()->delete($criteria); |
309 | 309 | } |
310 | 310 | |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | public function deleteByPk($keys) |
335 | 335 | { |
336 | 336 | if(func_num_args() > 1) |
337 | - $keys = func_get_args(); |
|
337 | + $keys=func_get_args(); |
|
338 | 338 | return $this->getCommand()->deleteByPk($keys); |
339 | 339 | } |
340 | 340 | |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | public function deleteAllByPks($keys) |
345 | 345 | { |
346 | 346 | if(func_num_args() > 1) |
347 | - $keys = func_get_args(); |
|
347 | + $keys=func_get_args(); |
|
348 | 348 | return $this->deleteByPk($keys); |
349 | 349 | } |
350 | 350 | |
@@ -354,11 +354,11 @@ discard block |
||
354 | 354 | * @param mixed parameter values. |
355 | 355 | * @return int number of records. |
356 | 356 | */ |
357 | - public function count($criteria=null,$parameters=array()) |
|
357 | + public function count($criteria=null, $parameters=array()) |
|
358 | 358 | { |
359 | - $args = func_num_args() > 1 ? array_slice(func_get_args(),1) : null; |
|
359 | + $args=func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
|
360 | 360 | if($criteria!==null) |
361 | - $criteria = $this->getCriteria($criteria,$parameters, $args); |
|
361 | + $criteria=$this->getCriteria($criteria, $parameters, $args); |
|
362 | 362 | return $this->getCommand()->count($criteria); |
363 | 363 | } |
364 | 364 | |
@@ -378,8 +378,8 @@ discard block |
||
378 | 378 | */ |
379 | 379 | public function update($data, $criteria, $parameters=array()) |
380 | 380 | { |
381 | - $args = func_num_args() > 2 ? array_slice(func_get_args(),2) : null; |
|
382 | - $criteria = $this->getCriteria($criteria,$parameters, $args); |
|
381 | + $args=func_num_args() > 2 ? array_slice(func_get_args(), 2) : null; |
|
382 | + $criteria=$this->getCriteria($criteria, $parameters, $args); |
|
383 | 383 | return $this->getCommand()->update($data, $criteria); |
384 | 384 | } |
385 | 385 | |
@@ -416,8 +416,8 @@ discard block |
||
416 | 416 | { |
417 | 417 | if(is_string($criteria)) |
418 | 418 | { |
419 | - $useArgs = !is_array($parameters) && is_array($args); |
|
420 | - return new TSqlCriteria($criteria,$useArgs ? $args : $parameters); |
|
419 | + $useArgs=!is_array($parameters) && is_array($args); |
|
420 | + return new TSqlCriteria($criteria, $useArgs ? $args : $parameters); |
|
421 | 421 | } |
422 | 422 | else if($criteria instanceof TSqlCriteria) |
423 | 423 | return $criteria; |
@@ -454,21 +454,21 @@ discard block |
||
454 | 454 | * @return mixed single record if method name starts with "findBy", 0 or more records |
455 | 455 | * if method name starts with "findAllBy" |
456 | 456 | */ |
457 | - public function __call($method,$args) |
|
457 | + public function __call($method, $args) |
|
458 | 458 | { |
459 | - $delete =false; |
|
460 | - if($findOne = substr(strtolower($method),0,6)==='findby') |
|
461 | - $condition = $method[6]==='_' ? substr($method,7) : substr($method,6); |
|
462 | - else if(substr(strtolower($method),0,9)==='findallby') |
|
463 | - $condition = $method[9]==='_' ? substr($method,10) : substr($method,9); |
|
464 | - else if($delete = substr(strtolower($method),0,8)==='deleteby') |
|
465 | - $condition = $method[8]==='_' ? substr($method,9) : substr($method,8); |
|
466 | - else if($delete = substr(strtolower($method),0,11)==='deleteallby') |
|
467 | - $condition = $method[11]==='_' ? substr($method,12) : substr($method,11); |
|
459 | + $delete=false; |
|
460 | + if($findOne=substr(strtolower($method), 0, 6)==='findby') |
|
461 | + $condition=$method[6]==='_' ? substr($method, 7) : substr($method, 6); |
|
462 | + else if(substr(strtolower($method), 0, 9)==='findallby') |
|
463 | + $condition=$method[9]==='_' ? substr($method, 10) : substr($method, 9); |
|
464 | + else if($delete=substr(strtolower($method), 0, 8)==='deleteby') |
|
465 | + $condition=$method[8]==='_' ? substr($method, 9) : substr($method, 8); |
|
466 | + else if($delete=substr(strtolower($method), 0, 11)==='deleteallby') |
|
467 | + $condition=$method[11]==='_' ? substr($method, 12) : substr($method, 11); |
|
468 | 468 | else |
469 | 469 | return null; |
470 | 470 | |
471 | - $criteria = $this->getCommand()->createCriteriaFromString($method, $condition, $args); |
|
471 | + $criteria=$this->getCommand()->createCriteriaFromString($method, $condition, $args); |
|
472 | 472 | if($delete) |
473 | 473 | return $this->deleteAll($criteria); |
474 | 474 | else |
@@ -115,8 +115,7 @@ discard block |
||
115 | 115 | $columns = $this->getTableInfo()->getColumns(); |
116 | 116 | $this->getInputRepeater()->setDataSource($columns); |
117 | 117 | $this->getInputRepeater()->dataBind(); |
118 | - } |
|
119 | - else |
|
118 | + } else |
|
120 | 119 | { |
121 | 120 | if($this->_editRenderer===null) |
122 | 121 | $this->createEditRenderer($record, $classPath); |
@@ -140,8 +139,7 @@ discard block |
||
140 | 139 | $index = $this->getControls()->remove($this->getInputRepeater()); |
141 | 140 | $this->getControls()->insertAt($index,$this->_editRenderer); |
142 | 141 | $this->_editRenderer->setData($record); |
143 | - } |
|
144 | - else |
|
142 | + } else |
|
145 | 143 | { |
146 | 144 | throw new TConfigurationException( |
147 | 145 | 'scaffold_invalid_edit_renderer', $this->getID(), get_class($record)); |
@@ -204,15 +202,13 @@ discard block |
||
204 | 202 | $column = $table->getColumn($item->getCustomData()); |
205 | 203 | $builder->loadScaffoldInput($this, $item, $column, $record); |
206 | 204 | } |
207 | - } |
|
208 | - else |
|
205 | + } else |
|
209 | 206 | { |
210 | 207 | $this->_editRenderer->updateRecord($record); |
211 | 208 | } |
212 | 209 | $record->save(); |
213 | 210 | return true; |
214 | - } |
|
215 | - else if($this->_editRenderer!==null) |
|
211 | + } else if($this->_editRenderer!==null) |
|
216 | 212 | { |
217 | 213 | //preserve the form data. |
218 | 214 | $this->_editRenderer->updateRecord($this->getCurrentRecord()); |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | public function setRecordPk($value) |
91 | 91 | { |
92 | 92 | $this->clearRecordObject(); |
93 | - $val = TPropertyValue::ensureArray($value); |
|
93 | + $val=TPropertyValue::ensureArray($value); |
|
94 | 94 | $this->setViewState('PK', count($val) > 0 ? $val : null); |
95 | 95 | } |
96 | 96 | |
@@ -115,11 +115,11 @@ discard block |
||
115 | 115 | */ |
116 | 116 | public function initializeEditForm() |
117 | 117 | { |
118 | - $record = $this->getCurrentRecord(); |
|
119 | - $classPath = $this->getEditRenderer(); |
|
120 | - if($classPath === '') |
|
118 | + $record=$this->getCurrentRecord(); |
|
119 | + $classPath=$this->getEditRenderer(); |
|
120 | + if($classPath==='') |
|
121 | 121 | { |
122 | - $columns = $this->getTableInfo()->getColumns(); |
|
122 | + $columns=$this->getTableInfo()->getColumns(); |
|
123 | 123 | $this->getInputRepeater()->setDataSource($columns); |
124 | 124 | $this->getInputRepeater()->dataBind(); |
125 | 125 | } |
@@ -141,11 +141,11 @@ discard block |
||
141 | 141 | */ |
142 | 142 | protected function createEditRenderer($record, $classPath) |
143 | 143 | { |
144 | - $this->_editRenderer = Prado::createComponent($classPath); |
|
144 | + $this->_editRenderer=Prado::createComponent($classPath); |
|
145 | 145 | if($this->_editRenderer instanceof IScaffoldEditRenderer) |
146 | 146 | { |
147 | - $index = $this->getControls()->remove($this->getInputRepeater()); |
|
148 | - $this->getControls()->insertAt($index,$this->_editRenderer); |
|
147 | + $index=$this->getControls()->remove($this->getInputRepeater()); |
|
148 | + $this->getControls()->insertAt($index, $this->_editRenderer); |
|
149 | 149 | $this->_editRenderer->setData($record); |
150 | 150 | } |
151 | 151 | else |
@@ -160,16 +160,16 @@ discard block |
||
160 | 160 | */ |
161 | 161 | protected function createRepeaterEditItem($sender, $param) |
162 | 162 | { |
163 | - $type = $param->getItem()->getItemType(); |
|
163 | + $type=$param->getItem()->getItemType(); |
|
164 | 164 | if($type==TListItemType::Item || $type==TListItemType::AlternatingItem) |
165 | 165 | { |
166 | - $item = $param->getItem(); |
|
167 | - $column = $item->getData(); |
|
166 | + $item=$param->getItem(); |
|
167 | + $column=$item->getData(); |
|
168 | 168 | if($column===null) |
169 | 169 | return; |
170 | 170 | |
171 | - $record = $this->getCurrentRecord(); |
|
172 | - $builder = $this->getScaffoldInputBuilder($record); |
|
171 | + $record=$this->getCurrentRecord(); |
|
172 | + $builder=$this->getScaffoldInputBuilder($record); |
|
173 | 173 | $builder->createScaffoldInput($this, $item, $column, $record); |
174 | 174 | } |
175 | 175 | } |
@@ -201,14 +201,14 @@ discard block |
||
201 | 201 | { |
202 | 202 | if($this->getPage()->getIsValid()) |
203 | 203 | { |
204 | - $record = $this->getCurrentRecord(); |
|
204 | + $record=$this->getCurrentRecord(); |
|
205 | 205 | if($this->_editRenderer===null) |
206 | 206 | { |
207 | - $table = $this->getTableInfo(); |
|
208 | - $builder = $this->getScaffoldInputBuilder($record); |
|
207 | + $table=$this->getTableInfo(); |
|
208 | + $builder=$this->getScaffoldInputBuilder($record); |
|
209 | 209 | foreach($this->getInputRepeater()->getItems() as $item) |
210 | 210 | { |
211 | - $column = $table->getColumn($item->getCustomData()); |
|
211 | + $column=$table->getColumn($item->getCustomData()); |
|
212 | 212 | $builder->loadScaffoldInput($this, $item, $column, $record); |
213 | 213 | } |
214 | 214 | } |
@@ -272,10 +272,10 @@ discard block |
||
272 | 272 | protected function getScaffoldInputBuilder($record) |
273 | 273 | { |
274 | 274 | static $_builders=array(); |
275 | - $class = get_class($record); |
|
275 | + $class=get_class($record); |
|
276 | 276 | if(!isset($_builders[$class])) |
277 | 277 | { |
278 | - $_builders[$class] = TScaffoldInputBase::createInputBuilder($record); |
|
278 | + $_builders[$class]=TScaffoldInputBase::createInputBuilder($record); |
|
279 | 279 | } |
280 | 280 | return $_builders[$class]; |
281 | 281 | } |
@@ -67,16 +67,14 @@ |
||
67 | 67 | throw new TActiveRecordException('ar_invalid_tablename_property', |
68 | 68 | get_class($record),self::TABLE_CONST); |
69 | 69 | return $value; |
70 | - } |
|
71 | - elseif ($class->hasMethod(self::TABLE_METHOD)) |
|
70 | + } elseif ($class->hasMethod(self::TABLE_METHOD)) |
|
72 | 71 | { |
73 | 72 | $value = $record->{self::TABLE_METHOD}(); |
74 | 73 | if(empty($value)) |
75 | 74 | throw new TActiveRecordException('ar_invalid_tablename_method', |
76 | 75 | get_class($record),self::TABLE_METHOD); |
77 | 76 | return $value; |
78 | - } |
|
79 | - else |
|
77 | + } else |
|
80 | 78 | return strtolower(get_class($record)); |
81 | 79 | } |
82 | 80 |
@@ -70,21 +70,21 @@ discard block |
||
70 | 70 | */ |
71 | 71 | protected function getRecordTableName(TActiveRecord $record) |
72 | 72 | { |
73 | - $class = new ReflectionClass($record); |
|
73 | + $class=new ReflectionClass($record); |
|
74 | 74 | if($class->hasConstant(self::TABLE_CONST)) |
75 | 75 | { |
76 | - $value = $class->getConstant(self::TABLE_CONST); |
|
76 | + $value=$class->getConstant(self::TABLE_CONST); |
|
77 | 77 | if(empty($value)) |
78 | 78 | throw new TActiveRecordException('ar_invalid_tablename_property', |
79 | - get_class($record),self::TABLE_CONST); |
|
79 | + get_class($record), self::TABLE_CONST); |
|
80 | 80 | return $value; |
81 | 81 | } |
82 | - elseif ($class->hasMethod(self::TABLE_METHOD)) |
|
82 | + elseif($class->hasMethod(self::TABLE_METHOD)) |
|
83 | 83 | { |
84 | - $value = $record->{self::TABLE_METHOD}(); |
|
84 | + $value=$record->{self::TABLE_METHOD}(); |
|
85 | 85 | if(empty($value)) |
86 | 86 | throw new TActiveRecordException('ar_invalid_tablename_method', |
87 | - get_class($record),self::TABLE_METHOD); |
|
87 | + get_class($record), self::TABLE_METHOD); |
|
88 | 88 | return $value; |
89 | 89 | } |
90 | 90 | else |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | */ |
99 | 99 | public function getRecordTableInfo(TActiveRecord $record) |
100 | 100 | { |
101 | - $tableName = $this->getRecordTableName($record); |
|
101 | + $tableName=$this->getRecordTableName($record); |
|
102 | 102 | return $this->getTableInfo($record->getDbConnection(), $tableName); |
103 | 103 | } |
104 | 104 | |
@@ -110,27 +110,27 @@ discard block |
||
110 | 110 | */ |
111 | 111 | public function getTableInfo(TDbConnection $connection, $tableName) |
112 | 112 | { |
113 | - $connStr = $connection->getConnectionString(); |
|
114 | - $key = $connStr.$tableName; |
|
113 | + $connStr=$connection->getConnectionString(); |
|
114 | + $key=$connStr.$tableName; |
|
115 | 115 | if(!isset($this->_tables[$key])) |
116 | 116 | { |
117 | 117 | //call this first to ensure that unserializing the cache |
118 | 118 | //will find the correct driver dependent classes. |
119 | 119 | if(!isset($this->_meta[$connStr])) |
120 | 120 | { |
121 | - $this->_meta[$connStr] = TDbMetaData::getInstance($connection); |
|
121 | + $this->_meta[$connStr]=TDbMetaData::getInstance($connection); |
|
122 | 122 | } |
123 | 123 | |
124 | - $tableInfo = null; |
|
124 | + $tableInfo=null; |
|
125 | 125 | if(($cache=$this->getManager()->getCache())!==null) |
126 | - $tableInfo = $cache->get($key); |
|
126 | + $tableInfo=$cache->get($key); |
|
127 | 127 | if(empty($tableInfo)) |
128 | 128 | { |
129 | - $tableInfo = $this->_meta[$connStr]->getTableInfo($tableName); |
|
129 | + $tableInfo=$this->_meta[$connStr]->getTableInfo($tableName); |
|
130 | 130 | if($cache!==null) |
131 | 131 | $cache->set($key, $tableInfo); |
132 | 132 | } |
133 | - $this->_tables[$key] = $tableInfo; |
|
133 | + $this->_tables[$key]=$tableInfo; |
|
134 | 134 | } |
135 | 135 | return $this->_tables[$key]; |
136 | 136 | } |
@@ -141,16 +141,16 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public function getCommand(TActiveRecord $record) |
143 | 143 | { |
144 | - $conn = $record->getDbConnection(); |
|
145 | - $connStr = $conn->getConnectionString(); |
|
146 | - $tableInfo = $this->getRecordTableInfo($record); |
|
144 | + $conn=$record->getDbConnection(); |
|
145 | + $connStr=$conn->getConnectionString(); |
|
146 | + $tableInfo=$this->getRecordTableInfo($record); |
|
147 | 147 | if(!isset($this->_commandBuilders[$connStr])) |
148 | 148 | { |
149 | - $builder = $tableInfo->createCommandBuilder($record->getDbConnection()); |
|
150 | - $command = new TDataGatewayCommand($builder); |
|
151 | - $command->OnCreateCommand[] = array($this, 'onCreateCommand'); |
|
152 | - $command->OnExecuteCommand[] = array($this, 'onExecuteCommand'); |
|
153 | - $this->_commandBuilders[$connStr] = $command; |
|
149 | + $builder=$tableInfo->createCommandBuilder($record->getDbConnection()); |
|
150 | + $command=new TDataGatewayCommand($builder); |
|
151 | + $command->OnCreateCommand[]=array($this, 'onCreateCommand'); |
|
152 | + $command->OnExecuteCommand[]=array($this, 'onExecuteCommand'); |
|
153 | + $this->_commandBuilders[$connStr]=$command; |
|
154 | 154 | |
155 | 155 | } |
156 | 156 | $this->_commandBuilders[$connStr]->getBuilder()->setTableInfo($tableInfo); |
@@ -200,9 +200,9 @@ discard block |
||
200 | 200 | * @param array primary name value pairs |
201 | 201 | * @return array record data |
202 | 202 | */ |
203 | - public function findRecordByPK(TActiveRecord $record,$keys) |
|
203 | + public function findRecordByPK(TActiveRecord $record, $keys) |
|
204 | 204 | { |
205 | - $command = $this->getCommand($record); |
|
205 | + $command=$this->getCommand($record); |
|
206 | 206 | return $command->findByPk($keys); |
207 | 207 | } |
208 | 208 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | */ |
229 | 229 | public function findRecordsByCriteria(TActiveRecord $record, $criteria, $iterator=false) |
230 | 230 | { |
231 | - $command = $this->getCommand($record); |
|
231 | + $command=$this->getCommand($record); |
|
232 | 232 | return $iterator ? $command->findAll($criteria) : $command->find($criteria); |
233 | 233 | } |
234 | 234 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | |
257 | 257 | public function findRecordsByIndex(TActiveRecord $record, $criteria, $fields, $values) |
258 | 258 | { |
259 | - return $this->getCommand($record)->findAllByIndex($criteria,$fields,$values); |
|
259 | + return $this->getCommand($record)->findAllByIndex($criteria, $fields, $values); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | public function insert(TActiveRecord $record) |
279 | 279 | { |
280 | 280 | //$this->updateAssociatedRecords($record,true); |
281 | - $result = $this->getCommand($record)->insert($this->getInsertValues($record)); |
|
281 | + $result=$this->getCommand($record)->insert($this->getInsertValues($record)); |
|
282 | 282 | if($result) |
283 | 283 | $this->updatePostInsert($record); |
284 | 284 | //$this->updateAssociatedRecords($record); |
@@ -291,12 +291,12 @@ discard block |
||
291 | 291 | */ |
292 | 292 | protected function updatePostInsert($record) |
293 | 293 | { |
294 | - $command = $this->getCommand($record); |
|
295 | - $tableInfo = $command->getTableInfo(); |
|
294 | + $command=$this->getCommand($record); |
|
295 | + $tableInfo=$command->getTableInfo(); |
|
296 | 296 | foreach($tableInfo->getColumns() as $name => $column) |
297 | 297 | { |
298 | 298 | if($column->hasSequence()) |
299 | - $record->setColumnValue($name,$command->getLastInsertID($column->getSequenceName())); |
|
299 | + $record->setColumnValue($name, $command->getLastInsertID($column->getSequenceName())); |
|
300 | 300 | } |
301 | 301 | } |
302 | 302 | |
@@ -307,20 +307,20 @@ discard block |
||
307 | 307 | protected function getInsertValues(TActiveRecord $record) |
308 | 308 | { |
309 | 309 | $values=array(); |
310 | - $tableInfo = $this->getCommand($record)->getTableInfo(); |
|
310 | + $tableInfo=$this->getCommand($record)->getTableInfo(); |
|
311 | 311 | foreach($tableInfo->getColumns() as $name=>$column) |
312 | 312 | { |
313 | 313 | if($column->getIsExcluded()) |
314 | 314 | continue; |
315 | - $value = $record->getColumnValue($name); |
|
316 | - if(!$column->getAllowNull() && $value===null && !$column->hasSequence() && ($column->getDefaultValue() === TDbTableColumn::UNDEFINED_VALUE)) |
|
315 | + $value=$record->getColumnValue($name); |
|
316 | + if(!$column->getAllowNull() && $value===null && !$column->hasSequence() && ($column->getDefaultValue()===TDbTableColumn::UNDEFINED_VALUE)) |
|
317 | 317 | { |
318 | 318 | throw new TActiveRecordException( |
319 | 319 | 'ar_value_must_not_be_null', get_class($record), |
320 | 320 | $tableInfo->getTableFullName(), $name); |
321 | 321 | } |
322 | 322 | if($value!==null) |
323 | - $values[$name] = $value; |
|
323 | + $values[$name]=$value; |
|
324 | 324 | } |
325 | 325 | return $values; |
326 | 326 | } |
@@ -333,8 +333,8 @@ discard block |
||
333 | 333 | public function update(TActiveRecord $record) |
334 | 334 | { |
335 | 335 | //$this->updateAssociatedRecords($record,true); |
336 | - list($data, $keys) = $this->getUpdateValues($record); |
|
337 | - $result = $this->getCommand($record)->updateByPk($data, $keys); |
|
336 | + list($data, $keys)=$this->getUpdateValues($record); |
|
337 | + $result=$this->getCommand($record)->updateByPk($data, $keys); |
|
338 | 338 | //$this->updateAssociatedRecords($record); |
339 | 339 | return $result; |
340 | 340 | } |
@@ -342,30 +342,30 @@ discard block |
||
342 | 342 | protected function getUpdateValues(TActiveRecord $record) |
343 | 343 | { |
344 | 344 | $values=array(); |
345 | - $tableInfo = $this->getCommand($record)->getTableInfo(); |
|
345 | + $tableInfo=$this->getCommand($record)->getTableInfo(); |
|
346 | 346 | $primary=array(); |
347 | 347 | foreach($tableInfo->getColumns() as $name=>$column) |
348 | 348 | { |
349 | 349 | if($column->getIsExcluded()) |
350 | 350 | continue; |
351 | - $value = $record->getColumnValue($name); |
|
352 | - if(!$column->getAllowNull() && $value===null && ($column->getDefaultValue() === TDbTableColumn::UNDEFINED_VALUE)) |
|
351 | + $value=$record->getColumnValue($name); |
|
352 | + if(!$column->getAllowNull() && $value===null && ($column->getDefaultValue()===TDbTableColumn::UNDEFINED_VALUE)) |
|
353 | 353 | { |
354 | 354 | throw new TActiveRecordException( |
355 | 355 | 'ar_value_must_not_be_null', get_class($record), |
356 | 356 | $tableInfo->getTableFullName(), $name); |
357 | 357 | } |
358 | 358 | if($column->getIsPrimaryKey()) |
359 | - $primary[$name] = $value; |
|
359 | + $primary[$name]=$value; |
|
360 | 360 | else |
361 | - $values[$name] = $value; |
|
361 | + $values[$name]=$value; |
|
362 | 362 | } |
363 | - return array($values,$primary); |
|
363 | + return array($values, $primary); |
|
364 | 364 | } |
365 | 365 | |
366 | - protected function updateAssociatedRecords(TActiveRecord $record,$updateBelongsTo=false) |
|
366 | + protected function updateAssociatedRecords(TActiveRecord $record, $updateBelongsTo=false) |
|
367 | 367 | { |
368 | - $context = new TActiveRecordRelationContext($record); |
|
368 | + $context=new TActiveRecordRelationContext($record); |
|
369 | 369 | return $context->updateAssociatedRecords($updateBelongsTo); |
370 | 370 | } |
371 | 371 | |
@@ -381,12 +381,12 @@ discard block |
||
381 | 381 | |
382 | 382 | protected function getPrimaryKeyValues(TActiveRecord $record) |
383 | 383 | { |
384 | - $tableInfo = $this->getCommand($record)->getTableInfo(); |
|
384 | + $tableInfo=$this->getCommand($record)->getTableInfo(); |
|
385 | 385 | $primary=array(); |
386 | 386 | foreach($tableInfo->getColumns() as $name=>$column) |
387 | 387 | { |
388 | 388 | if($column->getIsPrimaryKey()) |
389 | - $primary[$name] = $record->getColumnValue($name); |
|
389 | + $primary[$name]=$record->getColumnValue($name); |
|
390 | 390 | } |
391 | 391 | return $primary; |
392 | 392 | } |
@@ -419,12 +419,12 @@ discard block |
||
419 | 419 | * @param TActiveRecord active record |
420 | 420 | * @param TActiveRecordCriteria data for the command. |
421 | 421 | */ |
422 | - protected function raiseCommandEvent($event,$command,$record,$criteria) |
|
422 | + protected function raiseCommandEvent($event, $command, $record, $criteria) |
|
423 | 423 | { |
424 | 424 | if(!($criteria instanceof TSqlCriteria)) |
425 | - $criteria = new TActiveRecordCriteria(null,$criteria); |
|
426 | - $param = new TActiveRecordEventParameter($command,$record,$criteria); |
|
427 | - $manager = $record->getRecordManager(); |
|
425 | + $criteria=new TActiveRecordCriteria(null, $criteria); |
|
426 | + $param=new TActiveRecordEventParameter($command, $record, $criteria); |
|
427 | + $manager=$record->getRecordManager(); |
|
428 | 428 | $manager->{$event}($param); |
429 | 429 | $record->{$event}($param); |
430 | 430 | } |
@@ -189,8 +189,7 @@ discard block |
||
189 | 189 | $this->_pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
190 | 190 | $this->_active=true; |
191 | 191 | $this->setConnectionCharset(); |
192 | - } |
|
193 | - catch(PDOException $e) |
|
192 | + } catch(PDOException $e) |
|
194 | 193 | { |
195 | 194 | throw new TDbException('dbconnection_open_failed',$e->getMessage()); |
196 | 195 | } |
@@ -343,8 +342,7 @@ discard block |
||
343 | 342 | { |
344 | 343 | $this->_pdo->beginTransaction(); |
345 | 344 | return $this->_transaction=Prado::createComponent($this->getTransactionClass(), $this); |
346 | - } |
|
347 | - else |
|
345 | + } else |
|
348 | 346 | throw new TDbException('dbconnection_connection_inactive'); |
349 | 347 | } |
350 | 348 |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @since 3.1.7 |
94 | 94 | */ |
95 | - const DEFAULT_TRANSACTION_CLASS = 'System.Data.TDbTransaction'; |
|
95 | + const DEFAULT_TRANSACTION_CLASS='System.Data.TDbTransaction'; |
|
96 | 96 | |
97 | 97 | private $_dsn=''; |
98 | 98 | private $_username=''; |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | /** |
107 | 107 | * @var TDbMetaData |
108 | 108 | */ |
109 | - private $_dbMeta = null; |
|
109 | + private $_dbMeta=null; |
|
110 | 110 | |
111 | 111 | /** |
112 | 112 | * @var string |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @param string Charset used for DB Connection (MySql & pgsql only). If not set, will use the default charset of your database server |
128 | 128 | * @see http://www.php.net/manual/en/function.PDO-construct.php |
129 | 129 | */ |
130 | - public function __construct($dsn='',$username='',$password='', $charset='') |
|
130 | + public function __construct($dsn='', $username='', $password='', $charset='') |
|
131 | 131 | { |
132 | 132 | $this->_dsn=$dsn; |
133 | 133 | $this->_username=$username; |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | public function __sleep() |
142 | 142 | { |
143 | 143 | // $this->close(); - DO NOT CLOSE the current connection as serializing doesn't neccessarily mean we don't this connection anymore in the current session |
144 | - return array_diff(parent::__sleep(),array("\0Prado\Data\TDbConnection\0_pdo","\0Prado\Data\TDbConnection\0_active")); |
|
144 | + return array_diff(parent::__sleep(), array("\0Prado\Data\TDbConnection\0_pdo", "\0Prado\Data\TDbConnection\0_active")); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -188,8 +188,8 @@ discard block |
||
188 | 188 | { |
189 | 189 | try |
190 | 190 | { |
191 | - $this->_pdo=new PDO($this->getConnectionString(),$this->getUsername(), |
|
192 | - $this->getPassword(),$this->_attributes); |
|
191 | + $this->_pdo=new PDO($this->getConnectionString(), $this->getUsername(), |
|
192 | + $this->getPassword(), $this->_attributes); |
|
193 | 193 | // This attribute is only useful for PDO::MySql driver. |
194 | 194 | // Ignore the warning if a driver doesn't understand this. |
195 | 195 | @$this->_pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | } |
200 | 200 | catch(PDOException $e) |
201 | 201 | { |
202 | - throw new TDbException('dbconnection_open_failed',$e->getMessage()); |
|
202 | + throw new TDbException('dbconnection_open_failed', $e->getMessage()); |
|
203 | 203 | } |
204 | 204 | } |
205 | 205 | } |
@@ -221,16 +221,16 @@ discard block |
||
221 | 221 | */ |
222 | 222 | protected function setConnectionCharset() |
223 | 223 | { |
224 | - if ($this->_charset === '' || $this->_active === false) |
|
224 | + if($this->_charset==='' || $this->_active===false) |
|
225 | 225 | return; |
226 | - switch ($this->_pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) |
|
226 | + switch($this->_pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) |
|
227 | 227 | { |
228 | 228 | case 'mysql': |
229 | 229 | case 'sqlite': |
230 | - $stmt = $this->_pdo->prepare('SET NAMES ?'); |
|
230 | + $stmt=$this->_pdo->prepare('SET NAMES ?'); |
|
231 | 231 | break; |
232 | 232 | case 'pgsql': |
233 | - $stmt = $this->_pdo->prepare('SET client_encoding TO ?'); |
|
233 | + $stmt=$this->_pdo->prepare('SET client_encoding TO ?'); |
|
234 | 234 | break; |
235 | 235 | default: |
236 | 236 | throw new TDbException('dbconnection_unsupported_driver_charset', $driver); |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | /** |
291 | 291 | * @return string the charset used for database connection. Defaults to emtpy string. |
292 | 292 | */ |
293 | - public function getCharset () |
|
293 | + public function getCharset() |
|
294 | 294 | { |
295 | 295 | return $this->_charset; |
296 | 296 | } |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | /** |
299 | 299 | * @param string the charset used for database connection |
300 | 300 | */ |
301 | - public function setCharset ($value) |
|
301 | + public function setCharset($value) |
|
302 | 302 | { |
303 | 303 | $this->_charset=$value; |
304 | 304 | $this->setConnectionCharset(); |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | public function createCommand($sql) |
322 | 322 | { |
323 | 323 | if($this->getActive()) |
324 | - return new TDbCommand($this,$sql); |
|
324 | + return new TDbCommand($this, $sql); |
|
325 | 325 | else |
326 | 326 | throw new TDbException('dbconnection_connection_inactive'); |
327 | 327 | } |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | */ |
372 | 372 | public function setTransactionClass($value) |
373 | 373 | { |
374 | - $this->_transactionClass = (string)$value; |
|
374 | + $this->_transactionClass=(string) $value; |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | /** |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | { |
440 | 440 | if($this->_dbMeta===null) |
441 | 441 | { |
442 | - $this->_dbMeta = TDbMetaData::getInstance($this); |
|
442 | + $this->_dbMeta=TDbMetaData::getInstance($this); |
|
443 | 443 | } |
444 | 444 | return $this->_dbMeta; |
445 | 445 | } |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | */ |
466 | 466 | public function setColumnCase($value) |
467 | 467 | { |
468 | - switch(TPropertyValue::ensureEnum($value,'Prado\\Data\\TDbColumnCaseMode')) |
|
468 | + switch(TPropertyValue::ensureEnum($value, 'Prado\\Data\\TDbColumnCaseMode')) |
|
469 | 469 | { |
470 | 470 | case TDbColumnCaseMode::Preserved: |
471 | 471 | $value=PDO::CASE_NATURAL; |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | $value=PDO::CASE_UPPER; |
478 | 478 | break; |
479 | 479 | } |
480 | - $this->setAttribute(PDO::ATTR_CASE,$value); |
|
480 | + $this->setAttribute(PDO::ATTR_CASE, $value); |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | /** |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | */ |
502 | 502 | public function setNullConversion($value) |
503 | 503 | { |
504 | - switch(TPropertyValue::ensureEnum($value,'Prado\\Data\\TDbNullConversionMode')) |
|
504 | + switch(TPropertyValue::ensureEnum($value, 'Prado\\Data\\TDbNullConversionMode')) |
|
505 | 505 | { |
506 | 506 | case TDbNullConversionMode::Preserved: |
507 | 507 | $value=PDO::NULL_NATURAL; |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | $value=PDO::NULL_TO_STRING; |
514 | 514 | break; |
515 | 515 | } |
516 | - $this->setAttribute(PDO::ATTR_ORACLE_NULLS,$value); |
|
516 | + $this->setAttribute(PDO::ATTR_ORACLE_NULLS, $value); |
|
517 | 517 | } |
518 | 518 | |
519 | 519 | /** |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | */ |
532 | 532 | public function setAutoCommit($value) |
533 | 533 | { |
534 | - $this->setAttribute(PDO::ATTR_AUTOCOMMIT,TPropertyValue::ensureBoolean($value)); |
|
534 | + $this->setAttribute(PDO::ATTR_AUTOCOMMIT, TPropertyValue::ensureBoolean($value)); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | /** |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | */ |
550 | 550 | public function setPersistent($value) |
551 | 551 | { |
552 | - return $this->setAttribute(PDO::ATTR_PERSISTENT,TPropertyValue::ensureBoolean($value)); |
|
552 | + return $this->setAttribute(PDO::ATTR_PERSISTENT, TPropertyValue::ensureBoolean($value)); |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | /** |
@@ -629,10 +629,10 @@ discard block |
||
629 | 629 | * @param mixed the attribute value |
630 | 630 | * @see http://www.php.net/manual/en/function.PDO-setAttribute.php |
631 | 631 | */ |
632 | - public function setAttribute($name,$value) |
|
632 | + public function setAttribute($name, $value) |
|
633 | 633 | { |
634 | 634 | if($this->_pdo instanceof PDO) |
635 | - $this->_pdo->setAttribute($name,$value); |
|
635 | + $this->_pdo->setAttribute($name, $value); |
|
636 | 636 | else |
637 | 637 | $this->_attributes[$name]=$value; |
638 | 638 | } |
@@ -63,8 +63,7 @@ discard block |
||
63 | 63 | { |
64 | 64 | $this->_connection->getPdoInstance()->commit(); |
65 | 65 | $this->_active=false; |
66 | - } |
|
67 | - else |
|
66 | + } else |
|
68 | 67 | throw new TDbException('dbtransaction_transaction_inactive'); |
69 | 68 | } |
70 | 69 | |
@@ -78,8 +77,7 @@ discard block |
||
78 | 77 | { |
79 | 78 | $this->_connection->getPdoInstance()->rollBack(); |
80 | 79 | $this->_active=false; |
81 | - } |
|
82 | - else |
|
80 | + } else |
|
83 | 81 | throw new TDbException('dbtransaction_transaction_inactive'); |
84 | 82 | } |
85 | 83 |
@@ -68,8 +68,7 @@ |
||
68 | 68 | $manager->configureXml($file); |
69 | 69 | $this->cacheSqlMapManager($manager); |
70 | 70 | } |
71 | - } |
|
72 | - elseif($this->getConnectionID() !== '') { |
|
71 | + } elseif($this->getConnectionID() !== '') { |
|
73 | 72 | $manager->setDbConnection($this->getDbConnection()); |
74 | 73 | } |
75 | 74 | return $manager; |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function clearCache() |
53 | 53 | { |
54 | - $cache = $this->getApplication()->getCache(); |
|
55 | - if($cache !== null) { |
|
54 | + $cache=$this->getApplication()->getCache(); |
|
55 | + if($cache!==null) { |
|
56 | 56 | $cache->delete($this->getCacheKey()); |
57 | 57 | } |
58 | 58 | } |
@@ -66,16 +66,16 @@ discard block |
||
66 | 66 | * @since 3.1.7 |
67 | 67 | */ |
68 | 68 | public function getSqlMapManager() { |
69 | - if(($manager = $this->loadCachedSqlMapManager())===null) |
|
69 | + if(($manager=$this->loadCachedSqlMapManager())===null) |
|
70 | 70 | { |
71 | - $manager = new TSqlMapManager($this->getDbConnection()); |
|
71 | + $manager=new TSqlMapManager($this->getDbConnection()); |
|
72 | 72 | if(strlen($file=$this->getConfigFile()) > 0) |
73 | 73 | { |
74 | 74 | $manager->configureXml($file); |
75 | 75 | $this->cacheSqlMapManager($manager); |
76 | 76 | } |
77 | 77 | } |
78 | - elseif($this->getConnectionID() !== '') { |
|
78 | + elseif($this->getConnectionID()!=='') { |
|
79 | 79 | $manager->setDbConnection($this->getDbConnection()); |
80 | 80 | } |
81 | 81 | return $manager; |
@@ -89,11 +89,11 @@ discard block |
||
89 | 89 | { |
90 | 90 | if($this->getEnableCache()) |
91 | 91 | { |
92 | - $cache = $this->getApplication()->getCache(); |
|
93 | - if($cache !== null) { |
|
94 | - $dependencies = null; |
|
95 | - if($this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
96 | - $dependencies = $manager->getCacheDependencies(); |
|
92 | + $cache=$this->getApplication()->getCache(); |
|
93 | + if($cache!==null) { |
|
94 | + $dependencies=null; |
|
95 | + if($this->getApplication()->getMode()!==TApplicationMode::Performance) |
|
96 | + $dependencies=$manager->getCacheDependencies(); |
|
97 | 97 | return $cache->set($this->getCacheKey(), $manager, 0, $dependencies); |
98 | 98 | } |
99 | 99 | } |
@@ -108,10 +108,10 @@ discard block |
||
108 | 108 | { |
109 | 109 | if($this->getEnableCache()) |
110 | 110 | { |
111 | - $cache = $this->getApplication()->getCache(); |
|
112 | - if($cache !== null) |
|
111 | + $cache=$this->getApplication()->getCache(); |
|
112 | + if($cache!==null) |
|
113 | 113 | { |
114 | - $manager = $cache->get($this->getCacheKey()); |
|
114 | + $manager=$cache->get($this->getCacheKey()); |
|
115 | 115 | if($manager instanceof TSqlMapManager) |
116 | 116 | return $manager; |
117 | 117 | } |
@@ -138,11 +138,11 @@ discard block |
||
138 | 138 | $this->_configFile=$value; |
139 | 139 | else |
140 | 140 | { |
141 | - $file = Prado::getPathOfNamespace($value,self::CONFIG_FILE_EXT); |
|
142 | - if($file === null || !is_file($file)) |
|
143 | - throw new TConfigurationException('sqlmap_configfile_invalid',$value); |
|
141 | + $file=Prado::getPathOfNamespace($value, self::CONFIG_FILE_EXT); |
|
142 | + if($file===null || !is_file($file)) |
|
143 | + throw new TConfigurationException('sqlmap_configfile_invalid', $value); |
|
144 | 144 | else |
145 | - $this->_configFile = $file; |
|
145 | + $this->_configFile=$file; |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function setEnableCache($value) |
154 | 154 | { |
155 | - $this->_enableCache = TPropertyValue::ensureBoolean($value); |
|
155 | + $this->_enableCache=TPropertyValue::ensureBoolean($value); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | */ |
178 | 178 | public function getClient() |
179 | 179 | { |
180 | - if($this->_sqlmap===null ) |
|
180 | + if($this->_sqlmap===null) |
|
181 | 181 | $this->_sqlmap=$this->createSqlMapGateway(); |
182 | 182 | return $this->_sqlmap; |
183 | 183 | } |
@@ -177,8 +177,7 @@ |
||
177 | 177 | try |
178 | 178 | { |
179 | 179 | return TPropertyAccess::get($object, $property->getProperty()); |
180 | - } |
|
181 | - catch (TInvalidPropertyException $e) |
|
180 | + } catch (TInvalidPropertyException $e) |
|
182 | 181 | { |
183 | 182 | throw new TSqlMapException( |
184 | 183 | 'sqlmap_unable_to_get_property_for_parameter', |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function __construct() |
43 | 43 | { |
44 | - $this->_properties = new TList; |
|
45 | - $this->_propertyMap = new TMap; |
|
44 | + $this->_properties=new TList; |
|
45 | + $this->_propertyMap=new TMap; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function setExtends($value) |
84 | 84 | { |
85 | - $this->_extend = $value; |
|
85 | + $this->_extend=$value; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -136,15 +136,15 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public function getPropertyValue($registry, $property, $parameterValue) |
138 | 138 | { |
139 | - $value = $this->getObjectValue($parameterValue,$property); |
|
139 | + $value=$this->getObjectValue($parameterValue, $property); |
|
140 | 140 | |
141 | 141 | if(($handler=$this->createTypeHandler($property, $registry))!==null) |
142 | - $value = $handler->getParameter($value); |
|
142 | + $value=$handler->getParameter($value); |
|
143 | 143 | |
144 | - $value = $this->nullifyDefaultValue($property,$value); |
|
144 | + $value=$this->nullifyDefaultValue($property, $value); |
|
145 | 145 | |
146 | - if(($type = $property->getType())!==null) |
|
147 | - $value = $registry->convertToType($type, $value); |
|
146 | + if(($type=$property->getType())!==null) |
|
147 | + $value=$registry->convertToType($type, $value); |
|
148 | 148 | |
149 | 149 | return $value; |
150 | 150 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | $type=$property->getTypeHandler() ? $property->getTypeHandler() : $property->getType(); |
162 | 162 | $handler=$registry->getTypeHandler($type); |
163 | 163 | if($handler===null && $property->getTypeHandler()) |
164 | - $handler = Prado::createComponent($type); |
|
164 | + $handler=Prado::createComponent($type); |
|
165 | 165 | return $handler; |
166 | 166 | } |
167 | 167 | |
@@ -172,13 +172,13 @@ discard block |
||
172 | 172 | * @return mixed property value. |
173 | 173 | * @throws TSqlMapException if property access is invalid. |
174 | 174 | */ |
175 | - protected function getObjectValue($object,$property) |
|
175 | + protected function getObjectValue($object, $property) |
|
176 | 176 | { |
177 | 177 | try |
178 | 178 | { |
179 | 179 | return TPropertyAccess::get($object, $property->getProperty()); |
180 | 180 | } |
181 | - catch (TInvalidPropertyException $e) |
|
181 | + catch(TInvalidPropertyException $e) |
|
182 | 182 | { |
183 | 183 | throw new TSqlMapException( |
184 | 184 | 'sqlmap_unable_to_get_property_for_parameter', |
@@ -196,12 +196,12 @@ discard block |
||
196 | 196 | * @param mixed current property value |
197 | 197 | * @return mixed null if NullValue matches currrent value. |
198 | 198 | */ |
199 | - protected function nullifyDefaultValue($property,$value) |
|
199 | + protected function nullifyDefaultValue($property, $value) |
|
200 | 200 | { |
201 | - if(($nullValue = $property->getNullValue())!==null) |
|
201 | + if(($nullValue=$property->getNullValue())!==null) |
|
202 | 202 | { |
203 | - if($nullValue === $value) |
|
204 | - $value = null; |
|
203 | + if($nullValue===$value) |
|
204 | + $value=null; |
|
205 | 205 | } |
206 | 206 | return $value; |
207 | 207 | } |