@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
207 | - * @return boolean true to post the inputs of the form on callback, default |
|
207 | + * @return string true to post the inputs of the form on callback, default |
|
208 | 208 | * is post the inputs on callback. |
209 | 209 | */ |
210 | 210 | public function getPostState() |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | } |
223 | 223 | |
224 | 224 | /** |
225 | - * @return integer callback request timeout. |
|
225 | + * @return string callback request timeout. |
|
226 | 226 | */ |
227 | 227 | public function getRequestTimeOut() |
228 | 228 | { |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
253 | - * @return boolean client-side viewstate will be updated on callback |
|
253 | + * @return boolean|string client-side viewstate will be updated on callback |
|
254 | 254 | * response if true. Default is true. |
255 | 255 | */ |
256 | 256 | public function getEnablePageStateUpdate() |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | */ |
247 | 247 | public function setEnablePageStateUpdate($value) |
248 | 248 | { |
249 | - $enabled = TPropertyValue::ensureBoolean($value); |
|
249 | + $enabled=TPropertyValue::ensureBoolean($value); |
|
250 | 250 | $this->setOption('EnablePageStateUpdate', $enabled); |
251 | 251 | } |
252 | 252 | |
@@ -256,8 +256,8 @@ discard block |
||
256 | 256 | */ |
257 | 257 | public function getEnablePageStateUpdate() |
258 | 258 | { |
259 | - $option = $this->getOption('EnablePageStateUpdate'); |
|
260 | - return ($option === null) ? true : $option; |
|
259 | + $option=$this->getOption('EnablePageStateUpdate'); |
|
260 | + return ($option===null) ? true : $option; |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | public function setPostBackTarget($value) |
275 | 275 | { |
276 | 276 | if($value instanceof TControl) |
277 | - $value = $value->getUniqueID(); |
|
277 | + $value=$value->getUniqueID(); |
|
278 | 278 | $this->setOption('EventTarget', $value); |
279 | 279 | } |
280 | 280 |
@@ -101,8 +101,7 @@ |
||
101 | 101 | $dt->format('j'), |
102 | 102 | $dt->format('Y') |
103 | 103 | ); |
104 | - } |
|
105 | - else |
|
104 | + } else |
|
106 | 105 | return parent::getDateTimeValue($container, $column, $record); |
107 | 106 | } |
108 | 107 | } |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | |
62 | 62 | protected function createDateControl($container, $column, $record) |
63 | 63 | { |
64 | - $control = parent::createDateControl($container, $column, $record); |
|
65 | - $value = $this->getRecordPropertyValue($column, $record); |
|
64 | + $control=parent::createDateControl($container, $column, $record); |
|
65 | + $value=$this->getRecordPropertyValue($column, $record); |
|
66 | 66 | if(!empty($value) && preg_match('/timestamp/i', $column->getDbType())) |
67 | 67 | $control->setTimestamp(intval($value)); |
68 | 68 | return $control; |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | |
71 | 71 | protected function createDateTimeControl($container, $column, $record) |
72 | 72 | { |
73 | - $value = $this->getRecordPropertyValue($column, $record); |
|
74 | - $time = parent::createDateTimeControl($container, $column, $record); |
|
73 | + $value=$this->getRecordPropertyValue($column, $record); |
|
74 | + $time=parent::createDateTimeControl($container, $column, $record); |
|
75 | 75 | if(!empty($value) && preg_match('/timestamp/i', $column->getDbType())) |
76 | 76 | { |
77 | - $dt = new \DateTime; |
|
77 | + $dt=new \DateTime; |
|
78 | 78 | $dt->setTimestamp(intval($value)); |
79 | 79 | $time[1]->setSelectedValue($dt->format('G')); |
80 | 80 | $time[2]->setSelectedValue($dt->format('i')); |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | { |
88 | 88 | if(preg_match('/timestamp/i', $column->getDbType())) |
89 | 89 | { |
90 | - $time = $container->findControl(self::DEFAULT_ID)->getTimestamp(); |
|
91 | - $dt = new \DateTime; |
|
90 | + $time=$container->findControl(self::DEFAULT_ID)->getTimestamp(); |
|
91 | + $dt=new \DateTime; |
|
92 | 92 | $dt->setTimestamp($time); |
93 | - $hour = $container->findControl('scaffold_time_hour')->getSelectedValue(); |
|
94 | - $mins = $container->findControl('scaffold_time_min')->getSelectedValue(); |
|
95 | - $secs = $container->findControl('scaffold_time_sec')->getSelectedValue(); |
|
93 | + $hour=$container->findControl('scaffold_time_hour')->getSelectedValue(); |
|
94 | + $mins=$container->findControl('scaffold_time_min')->getSelectedValue(); |
|
95 | + $secs=$container->findControl('scaffold_time_sec')->getSelectedValue(); |
|
96 | 96 | return $s->getTimeStamp( |
97 | 97 | $hour, |
98 | 98 | $mins, |
@@ -35,6 +35,8 @@ |
||
35 | 35 | * @param TList the data to be iterated through |
36 | 36 | * @param integer start index |
37 | 37 | * @param integer number of items to be iterated through |
38 | + * @param integer $startIndex |
|
39 | + * @param integer $count |
|
38 | 40 | */ |
39 | 41 | public function __construct(TList $list, $startIndex, $count) |
40 | 42 | { |
@@ -38,13 +38,13 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function __construct(TList $list, $startIndex, $count) |
40 | 40 | { |
41 | - $this->_list = $list; |
|
42 | - $this->_index = 0; |
|
43 | - $this->_startIndex = $startIndex; |
|
41 | + $this->_list=$list; |
|
42 | + $this->_index=0; |
|
43 | + $this->_startIndex=$startIndex; |
|
44 | 44 | if($startIndex + $count > $list->getCount()) |
45 | - $this->_count = $list->getCount() - $startIndex; |
|
45 | + $this->_count=$list->getCount() - $startIndex; |
|
46 | 46 | else |
47 | - $this->_count = $count; |
|
47 | + $this->_count=$count; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function rewind() |
55 | 55 | { |
56 | - $this->_index = 0; |
|
56 | + $this->_index=0; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -34,6 +34,8 @@ |
||
34 | 34 | /** |
35 | 35 | * Constructor. |
36 | 36 | * @param array the data to be iterated through |
37 | + * @param integer $startIndex |
|
38 | + * @param integer $count |
|
37 | 39 | */ |
38 | 40 | public function __construct(TMap $map, $startIndex, $count) |
39 | 41 | { |
@@ -37,14 +37,14 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function __construct(TMap $map, $startIndex, $count) |
39 | 39 | { |
40 | - $this->_map = $map; |
|
41 | - $this->_index = 0; |
|
42 | - $this->_startIndex = $startIndex; |
|
40 | + $this->_map=$map; |
|
41 | + $this->_index=0; |
|
42 | + $this->_startIndex=$startIndex; |
|
43 | 43 | if($startIndex + $count > $map->getCount()) |
44 | - $this->_count = $map->getCount() - $startIndex; |
|
44 | + $this->_count=$map->getCount() - $startIndex; |
|
45 | 45 | else |
46 | - $this->_count = $count; |
|
47 | - $this->_iterator = $map->getIterator(); |
|
46 | + $this->_count=$count; |
|
47 | + $this->_iterator=$map->getIterator(); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | public function rewind() |
55 | 55 | { |
56 | 56 | $this->_iterator->rewind(); |
57 | - for($i = 0;$i < $this->_startIndex;++$i) |
|
57 | + for($i=0; $i < $this->_startIndex; ++$i) |
|
58 | 58 | $this->_iterator->next(); |
59 | - $this->_index = 0; |
|
59 | + $this->_index=0; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
168 | - * @return TDataGatewayCommand |
|
168 | + * @return \Prado\Data\DataGateway\TDataGatewayCommand |
|
169 | 169 | */ |
170 | 170 | protected function getCommandBuilder() |
171 | 171 | { |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
176 | - * @return TDataGatewayCommand |
|
176 | + * @return \Prado\Data\DataGateway\TDataGatewayCommand |
|
177 | 177 | */ |
178 | 178 | protected function getForeignCommandBuilder() |
179 | 179 | { |
@@ -210,6 +210,7 @@ discard block |
||
210 | 210 | * @param string active record class name. |
211 | 211 | * @param array row data |
212 | 212 | * @param array foreign key column names |
213 | + * @param string $type |
|
213 | 214 | * @return TActiveRecord |
214 | 215 | */ |
215 | 216 | protected function createFkObject($type, $row, $foreignKeys) |
@@ -343,6 +344,9 @@ discard block |
||
343 | 344 | return $this->getCommandBuilder()->onExecuteCommand($command, $command->execute()) > 0; |
344 | 345 | } |
345 | 346 | |
347 | + /** |
|
348 | + * @param TActiveRecord $obj |
|
349 | + */ |
|
346 | 350 | private function updateAssociationTable($obj, $fkObjects, $builder) |
347 | 351 | { |
348 | 352 | $source = $this->getSourceRecordValues($obj); |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | private $_association; |
90 | 90 | private $_sourceTable; |
91 | 91 | private $_foreignTable; |
92 | - private $_association_columns = []; |
|
92 | + private $_association_columns=[]; |
|
93 | 93 | |
94 | 94 | /** |
95 | 95 | * Get the foreign key index values from the results and make calls to the |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | */ |
99 | 99 | protected function collectForeignObjects(&$results) |
100 | 100 | { |
101 | - list($sourceKeys, $foreignKeys) = $this->getRelationForeignKeys(); |
|
102 | - $properties = array_values($sourceKeys); |
|
103 | - $indexValues = $this->getIndexValues($properties, $results); |
|
101 | + list($sourceKeys, $foreignKeys)=$this->getRelationForeignKeys(); |
|
102 | + $properties=array_values($sourceKeys); |
|
103 | + $indexValues=$this->getIndexValues($properties, $results); |
|
104 | 104 | $this->fetchForeignObjects($results, $foreignKeys, $indexValues, $sourceKeys); |
105 | 105 | } |
106 | 106 | |
@@ -109,10 +109,10 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function getRelationForeignKeys() |
111 | 111 | { |
112 | - $association = $this->getAssociationTable(); |
|
113 | - $sourceKeys = $this->findForeignKeys($association, $this->getSourceRecord(), true); |
|
114 | - $fkObject = $this->getContext()->getForeignRecordFinder(); |
|
115 | - $foreignKeys = $this->findForeignKeys($association, $fkObject); |
|
112 | + $association=$this->getAssociationTable(); |
|
113 | + $sourceKeys=$this->findForeignKeys($association, $this->getSourceRecord(), true); |
|
114 | + $fkObject=$this->getContext()->getForeignRecordFinder(); |
|
115 | + $foreignKeys=$this->findForeignKeys($association, $fkObject); |
|
116 | 116 | return [$sourceKeys, $foreignKeys]; |
117 | 117 | } |
118 | 118 | |
@@ -121,18 +121,18 @@ discard block |
||
121 | 121 | */ |
122 | 122 | protected function getAssociationTable() |
123 | 123 | { |
124 | - if($this->_association === null) |
|
124 | + if($this->_association===null) |
|
125 | 125 | { |
126 | - $gateway = $this->getSourceRecord()->getRecordGateway(); |
|
127 | - $conn = $this->getSourceRecord()->getDbConnection(); |
|
126 | + $gateway=$this->getSourceRecord()->getRecordGateway(); |
|
127 | + $conn=$this->getSourceRecord()->getDbConnection(); |
|
128 | 128 | //table name may include the fk column name separated with a dot. |
129 | - $table = explode('.', $this->getContext()->getAssociationTable()); |
|
129 | + $table=explode('.', $this->getContext()->getAssociationTable()); |
|
130 | 130 | if(count($table) > 1) |
131 | 131 | { |
132 | - $columns = preg_replace('/^\((.*)\)/', '\1', $table[1]); |
|
133 | - $this->_association_columns = preg_split('/\s*[, ]\*/', $columns); |
|
132 | + $columns=preg_replace('/^\((.*)\)/', '\1', $table[1]); |
|
133 | + $this->_association_columns=preg_split('/\s*[, ]\*/', $columns); |
|
134 | 134 | } |
135 | - $this->_association = $gateway->getTableInfo($conn, $table[0]); |
|
135 | + $this->_association=$gateway->getTableInfo($conn, $table[0]); |
|
136 | 136 | } |
137 | 137 | return $this->_association; |
138 | 138 | } |
@@ -142,10 +142,10 @@ discard block |
||
142 | 142 | */ |
143 | 143 | protected function getSourceTable() |
144 | 144 | { |
145 | - if($this->_sourceTable === null) |
|
145 | + if($this->_sourceTable===null) |
|
146 | 146 | { |
147 | - $gateway = $this->getSourceRecord()->getRecordGateway(); |
|
148 | - $this->_sourceTable = $gateway->getRecordTableInfo($this->getSourceRecord()); |
|
147 | + $gateway=$this->getSourceRecord()->getRecordGateway(); |
|
148 | + $this->_sourceTable=$gateway->getRecordTableInfo($this->getSourceRecord()); |
|
149 | 149 | } |
150 | 150 | return $this->_sourceTable; |
151 | 151 | } |
@@ -155,11 +155,11 @@ discard block |
||
155 | 155 | */ |
156 | 156 | protected function getForeignTable() |
157 | 157 | { |
158 | - if($this->_foreignTable === null) |
|
158 | + if($this->_foreignTable===null) |
|
159 | 159 | { |
160 | - $gateway = $this->getSourceRecord()->getRecordGateway(); |
|
161 | - $fkObject = $this->getContext()->getForeignRecordFinder(); |
|
162 | - $this->_foreignTable = $gateway->getRecordTableInfo($fkObject); |
|
160 | + $gateway=$this->getSourceRecord()->getRecordGateway(); |
|
161 | + $fkObject=$this->getContext()->getForeignRecordFinder(); |
|
162 | + $this->_foreignTable=$gateway->getRecordTableInfo($fkObject); |
|
163 | 163 | } |
164 | 164 | return $this->_foreignTable; |
165 | 165 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | */ |
178 | 178 | protected function getForeignCommandBuilder() |
179 | 179 | { |
180 | - $obj = $this->getContext()->getForeignRecordFinder(); |
|
180 | + $obj=$this->getContext()->getForeignRecordFinder(); |
|
181 | 181 | return $this->getSourceRecord()->getRecordGateway()->getCommand($obj); |
182 | 182 | } |
183 | 183 | |
@@ -189,19 +189,19 @@ discard block |
||
189 | 189 | */ |
190 | 190 | protected function fetchForeignObjects(&$results, $foreignKeys, $indexValues, $sourceKeys) |
191 | 191 | { |
192 | - $criteria = $this->getCriteria(); |
|
193 | - $finder = $this->getContext()->getForeignRecordFinder(); |
|
194 | - $type = get_class($finder); |
|
195 | - $command = $this->createCommand($criteria, $foreignKeys, $indexValues, $sourceKeys); |
|
196 | - $srcProps = array_keys($sourceKeys); |
|
197 | - $collections = []; |
|
192 | + $criteria=$this->getCriteria(); |
|
193 | + $finder=$this->getContext()->getForeignRecordFinder(); |
|
194 | + $type=get_class($finder); |
|
195 | + $command=$this->createCommand($criteria, $foreignKeys, $indexValues, $sourceKeys); |
|
196 | + $srcProps=array_keys($sourceKeys); |
|
197 | + $collections=[]; |
|
198 | 198 | foreach($this->getCommandBuilder()->onExecuteCommand($command, $command->query()) as $row) |
199 | 199 | { |
200 | - $hash = $this->getObjectHash($row, $srcProps); |
|
200 | + $hash=$this->getObjectHash($row, $srcProps); |
|
201 | 201 | foreach($srcProps as $column) |
202 | 202 | unset($row[$column]); |
203 | - $obj = $this->createFkObject($type, $row, $foreignKeys); |
|
204 | - $collections[$hash][] = $obj; |
|
203 | + $obj=$this->createFkObject($type, $row, $foreignKeys); |
|
204 | + $collections[$hash][]=$obj; |
|
205 | 205 | } |
206 | 206 | $this->setResultCollection($results, $collections, array_values($sourceKeys)); |
207 | 207 | } |
@@ -214,10 +214,10 @@ discard block |
||
214 | 214 | */ |
215 | 215 | protected function createFkObject($type, $row, $foreignKeys) |
216 | 216 | { |
217 | - $obj = TActiveRecord::createRecord($type, $row); |
|
217 | + $obj=TActiveRecord::createRecord($type, $row); |
|
218 | 218 | if(count($this->_association_columns) > 0) |
219 | 219 | { |
220 | - $i = 0; |
|
220 | + $i=0; |
|
221 | 221 | foreach($foreignKeys as $ref => $fk) |
222 | 222 | $obj->setColumnValue($ref, $row[$this->_association_columns[$i++]]); |
223 | 223 | } |
@@ -232,20 +232,20 @@ discard block |
||
232 | 232 | */ |
233 | 233 | public function createCommand($criteria, $foreignKeys, $indexValues, $sourceKeys) |
234 | 234 | { |
235 | - $innerJoin = $this->getAssociationJoin($foreignKeys, $indexValues, $sourceKeys); |
|
236 | - $fkTable = $this->getForeignTable()->getTableFullName(); |
|
237 | - $srcColumns = $this->getSourceColumns($sourceKeys); |
|
238 | - if(($where = $criteria->getCondition()) === null) |
|
239 | - $where = '1=1'; |
|
240 | - $sql = "SELECT {$fkTable}.*, {$srcColumns} FROM {$fkTable} {$innerJoin} WHERE {$where}"; |
|
235 | + $innerJoin=$this->getAssociationJoin($foreignKeys, $indexValues, $sourceKeys); |
|
236 | + $fkTable=$this->getForeignTable()->getTableFullName(); |
|
237 | + $srcColumns=$this->getSourceColumns($sourceKeys); |
|
238 | + if(($where=$criteria->getCondition())===null) |
|
239 | + $where='1=1'; |
|
240 | + $sql="SELECT {$fkTable}.*, {$srcColumns} FROM {$fkTable} {$innerJoin} WHERE {$where}"; |
|
241 | 241 | |
242 | - $parameters = $criteria->getParameters()->toArray(); |
|
243 | - $ordering = $criteria->getOrdersBy(); |
|
244 | - $limit = $criteria->getLimit(); |
|
245 | - $offset = $criteria->getOffset(); |
|
242 | + $parameters=$criteria->getParameters()->toArray(); |
|
243 | + $ordering=$criteria->getOrdersBy(); |
|
244 | + $limit=$criteria->getLimit(); |
|
245 | + $offset=$criteria->getOffset(); |
|
246 | 246 | |
247 | - $builder = $this->getForeignCommandBuilder()->getBuilder(); |
|
248 | - $command = $builder->applyCriterias($sql, $parameters, $ordering, $limit, $offset); |
|
247 | + $builder=$this->getForeignCommandBuilder()->getBuilder(); |
|
248 | + $command=$builder->applyCriterias($sql, $parameters, $ordering, $limit, $offset); |
|
249 | 249 | $this->getCommandBuilder()->onCreateCommand($command, $criteria); |
250 | 250 | return $command; |
251 | 251 | } |
@@ -256,12 +256,12 @@ discard block |
||
256 | 256 | */ |
257 | 257 | protected function getSourceColumns($sourceKeys) |
258 | 258 | { |
259 | - $columns = []; |
|
260 | - $table = $this->getAssociationTable(); |
|
261 | - $tableName = $table->getTableFullName(); |
|
262 | - $columnNames = array_merge(array_keys($sourceKeys), $this->_association_columns); |
|
259 | + $columns=[]; |
|
260 | + $table=$this->getAssociationTable(); |
|
261 | + $tableName=$table->getTableFullName(); |
|
262 | + $columnNames=array_merge(array_keys($sourceKeys), $this->_association_columns); |
|
263 | 263 | foreach($columnNames as $name) |
264 | - $columns[] = $tableName . '.' . $table->getColumn($name)->getColumnName(); |
|
264 | + $columns[]=$tableName.'.'.$table->getColumn($name)->getColumnName(); |
|
265 | 265 | return implode(', ', $columns); |
266 | 266 | } |
267 | 267 | |
@@ -274,26 +274,26 @@ discard block |
||
274 | 274 | */ |
275 | 275 | protected function getAssociationJoin($foreignKeys, $indexValues, $sourceKeys) |
276 | 276 | { |
277 | - $refInfo = $this->getAssociationTable(); |
|
278 | - $fkInfo = $this->getForeignTable(); |
|
277 | + $refInfo=$this->getAssociationTable(); |
|
278 | + $fkInfo=$this->getForeignTable(); |
|
279 | 279 | |
280 | - $refTable = $refInfo->getTableFullName(); |
|
281 | - $fkTable = $fkInfo->getTableFullName(); |
|
280 | + $refTable=$refInfo->getTableFullName(); |
|
281 | + $fkTable=$fkInfo->getTableFullName(); |
|
282 | 282 | |
283 | - $joins = []; |
|
284 | - $hasAssociationColumns = count($this->_association_columns) > 0; |
|
285 | - $i = 0; |
|
283 | + $joins=[]; |
|
284 | + $hasAssociationColumns=count($this->_association_columns) > 0; |
|
285 | + $i=0; |
|
286 | 286 | foreach($foreignKeys as $ref => $fk) |
287 | 287 | { |
288 | 288 | if($hasAssociationColumns) |
289 | - $refField = $refInfo->getColumn($this->_association_columns[$i++])->getColumnName(); |
|
289 | + $refField=$refInfo->getColumn($this->_association_columns[$i++])->getColumnName(); |
|
290 | 290 | else |
291 | - $refField = $refInfo->getColumn($ref)->getColumnName(); |
|
292 | - $fkField = $fkInfo->getColumn($fk)->getColumnName(); |
|
293 | - $joins[] = "{$fkTable}.{$fkField} = {$refTable}.{$refField}"; |
|
291 | + $refField=$refInfo->getColumn($ref)->getColumnName(); |
|
292 | + $fkField=$fkInfo->getColumn($fk)->getColumnName(); |
|
293 | + $joins[]="{$fkTable}.{$fkField} = {$refTable}.{$refField}"; |
|
294 | 294 | } |
295 | - $joinCondition = implode(' AND ', $joins); |
|
296 | - $index = $this->getCommandBuilder()->getIndexKeyCondition($refInfo, array_keys($sourceKeys), $indexValues); |
|
295 | + $joinCondition=implode(' AND ', $joins); |
|
296 | + $index=$this->getCommandBuilder()->getIndexKeyCondition($refInfo, array_keys($sourceKeys), $indexValues); |
|
297 | 297 | return "INNER JOIN {$refTable} ON ({$joinCondition}) AND {$index}"; |
298 | 298 | } |
299 | 299 | |
@@ -303,15 +303,15 @@ discard block |
||
303 | 303 | */ |
304 | 304 | public function updateAssociatedRecords() |
305 | 305 | { |
306 | - $obj = $this->getContext()->getSourceRecord(); |
|
307 | - $fkObjects = &$obj->{$this->getContext()->getProperty()}; |
|
308 | - $success = true; |
|
309 | - if(($total = count($fkObjects)) > 0) |
|
306 | + $obj=$this->getContext()->getSourceRecord(); |
|
307 | + $fkObjects=&$obj->{$this->getContext()->getProperty()}; |
|
308 | + $success=true; |
|
309 | + if(($total=count($fkObjects)) > 0) |
|
310 | 310 | { |
311 | - $source = $this->getSourceRecord(); |
|
312 | - $builder = $this->getAssociationTableCommandBuilder(); |
|
313 | - for($i = 0;$i < $total;$i++) |
|
314 | - $success = $fkObjects[$i]->save() && $success; |
|
311 | + $source=$this->getSourceRecord(); |
|
312 | + $builder=$this->getAssociationTableCommandBuilder(); |
|
313 | + for($i=0; $i < $total; $i++) |
|
314 | + $success=$fkObjects[$i]->save() && $success; |
|
315 | 315 | return $this->updateAssociationTable($obj, $fkObjects, $builder) && $success; |
316 | 316 | } |
317 | 317 | return $success; |
@@ -322,57 +322,57 @@ discard block |
||
322 | 322 | */ |
323 | 323 | protected function getAssociationTableCommandBuilder() |
324 | 324 | { |
325 | - $conn = $this->getContext()->getSourceRecord()->getDbConnection(); |
|
325 | + $conn=$this->getContext()->getSourceRecord()->getDbConnection(); |
|
326 | 326 | return $this->getAssociationTable()->createCommandBuilder($conn); |
327 | 327 | } |
328 | 328 | |
329 | 329 | private function hasAssociationData($builder, $data) |
330 | 330 | { |
331 | - $condition = []; |
|
332 | - $table = $this->getAssociationTable(); |
|
331 | + $condition=[]; |
|
332 | + $table=$this->getAssociationTable(); |
|
333 | 333 | foreach($data as $name => $value) |
334 | - $condition[] = $table->getColumn($name)->getColumnName() . ' = ?'; |
|
335 | - $command = $builder->createCountCommand(implode(' AND ', $condition), array_values($data)); |
|
336 | - $result = $this->getCommandBuilder()->onExecuteCommand($command, intval($command->queryScalar())); |
|
334 | + $condition[]=$table->getColumn($name)->getColumnName().' = ?'; |
|
335 | + $command=$builder->createCountCommand(implode(' AND ', $condition), array_values($data)); |
|
336 | + $result=$this->getCommandBuilder()->onExecuteCommand($command, intval($command->queryScalar())); |
|
337 | 337 | return intval($result) > 0; |
338 | 338 | } |
339 | 339 | |
340 | 340 | private function addAssociationData($builder, $data) |
341 | 341 | { |
342 | - $command = $builder->createInsertCommand($data); |
|
342 | + $command=$builder->createInsertCommand($data); |
|
343 | 343 | return $this->getCommandBuilder()->onExecuteCommand($command, $command->execute()) > 0; |
344 | 344 | } |
345 | 345 | |
346 | 346 | private function updateAssociationTable($obj, $fkObjects, $builder) |
347 | 347 | { |
348 | - $source = $this->getSourceRecordValues($obj); |
|
349 | - $foreignKeys = $this->findForeignKeys($this->getAssociationTable(), $fkObjects[0]); |
|
350 | - $success = true; |
|
348 | + $source=$this->getSourceRecordValues($obj); |
|
349 | + $foreignKeys=$this->findForeignKeys($this->getAssociationTable(), $fkObjects[0]); |
|
350 | + $success=true; |
|
351 | 351 | foreach($fkObjects as $fkObject) |
352 | 352 | { |
353 | - $data = array_merge($source, $this->getForeignObjectValues($foreignKeys, $fkObject)); |
|
353 | + $data=array_merge($source, $this->getForeignObjectValues($foreignKeys, $fkObject)); |
|
354 | 354 | if(!$this->hasAssociationData($builder, $data)) |
355 | - $success = $this->addAssociationData($builder, $data) && $success; |
|
355 | + $success=$this->addAssociationData($builder, $data) && $success; |
|
356 | 356 | } |
357 | 357 | return $success; |
358 | 358 | } |
359 | 359 | |
360 | 360 | private function getSourceRecordValues($obj) |
361 | 361 | { |
362 | - $sourceKeys = $this->findForeignKeys($this->getAssociationTable(), $obj); |
|
363 | - $indexValues = $this->getIndexValues(array_values($sourceKeys), $obj); |
|
364 | - $data = []; |
|
365 | - $i = 0; |
|
362 | + $sourceKeys=$this->findForeignKeys($this->getAssociationTable(), $obj); |
|
363 | + $indexValues=$this->getIndexValues(array_values($sourceKeys), $obj); |
|
364 | + $data=[]; |
|
365 | + $i=0; |
|
366 | 366 | foreach($sourceKeys as $name => $srcKey) |
367 | - $data[$name] = $indexValues[0][$i++]; |
|
367 | + $data[$name]=$indexValues[0][$i++]; |
|
368 | 368 | return $data; |
369 | 369 | } |
370 | 370 | |
371 | 371 | private function getForeignObjectValues($foreignKeys, $fkObject) |
372 | 372 | { |
373 | - $data = []; |
|
373 | + $data=[]; |
|
374 | 374 | foreach($foreignKeys as $name => $fKey) |
375 | - $data[$name] = $fkObject->getColumnValue($fKey); |
|
375 | + $data[$name]=$fkObject->getColumnValue($fKey); |
|
376 | 376 | return $data; |
377 | 377 | } |
378 | 378 | } |
@@ -95,6 +95,7 @@ discard block |
||
95 | 95 | |
96 | 96 | /** |
97 | 97 | * Fetch results for current relationship. |
98 | + * @param TActiveRecord $obj |
|
98 | 99 | * @return boolean always true. |
99 | 100 | */ |
100 | 101 | public function fetchResultsInto($obj) |
@@ -107,7 +108,6 @@ discard block |
||
107 | 108 | * Returns foreign keys in $fromRecord with source column names as key |
108 | 109 | * and foreign column names in the corresponding $matchesRecord as value. |
109 | 110 | * The method returns the first matching foreign key between these 2 records. |
110 | - * @param TActiveRecord $fromRecord |
|
111 | 111 | * @param TActiveRecord $matchesRecord |
112 | 112 | * @return array foreign keys with source column names as key and foreign column names as value. |
113 | 113 | */ |
@@ -215,6 +215,7 @@ discard block |
||
215 | 215 | * @param array source property names |
216 | 216 | * @param array foreign objects |
217 | 217 | * @param array foreign object field names. |
218 | + * @param TActiveRecord[] $fkObjects |
|
218 | 219 | */ |
219 | 220 | protected function populateResult(&$results, $properties, &$fkObjects, $fields) |
220 | 221 | { |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | |
34 | 34 | public function __construct(TActiveRecordRelationContext $context, $criteria) |
35 | 35 | { |
36 | - $this->_context = $context; |
|
37 | - $this->_criteria = $criteria; |
|
36 | + $this->_context=$context; |
|
37 | + $this->_criteria=$criteria; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -76,20 +76,20 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function __call($method, $args) |
78 | 78 | { |
79 | - static $stack = []; |
|
79 | + static $stack=[]; |
|
80 | 80 | |
81 | - $results = call_user_func_array([$this->getSourceRecord(),$method], $args); |
|
82 | - $validArray = is_array($results) && count($results) > 0; |
|
81 | + $results=call_user_func_array([$this->getSourceRecord(), $method], $args); |
|
82 | + $validArray=is_array($results) && count($results) > 0; |
|
83 | 83 | if($validArray || $results instanceof \ArrayAccess || $results instanceof TActiveRecord) |
84 | 84 | { |
85 | 85 | $this->collectForeignObjects($results); |
86 | - while($obj = array_pop($stack)) |
|
86 | + while($obj=array_pop($stack)) |
|
87 | 87 | $obj->collectForeignObjects($results); |
88 | 88 | } |
89 | 89 | elseif($results instanceof TActiveRecordRelation) |
90 | - $stack[] = $this; //call it later |
|
91 | - elseif($results === null || !$validArray) |
|
92 | - $stack = []; |
|
90 | + $stack[]=$this; //call it later |
|
91 | + elseif($results===null || !$validArray) |
|
92 | + $stack=[]; |
|
93 | 93 | return $results; |
94 | 94 | } |
95 | 95 | |
@@ -111,30 +111,30 @@ discard block |
||
111 | 111 | * @param TActiveRecord $matchesRecord |
112 | 112 | * @return array foreign keys with source column names as key and foreign column names as value. |
113 | 113 | */ |
114 | - protected function findForeignKeys($from, $matchesRecord, $loose = false) |
|
114 | + protected function findForeignKeys($from, $matchesRecord, $loose=false) |
|
115 | 115 | { |
116 | - $gateway = $matchesRecord->getRecordGateway(); |
|
117 | - $recordTableInfo = $gateway->getRecordTableInfo($matchesRecord); |
|
118 | - $matchingTableName = strtolower($recordTableInfo->getTableName()); |
|
119 | - $matchingFullTableName = strtolower($recordTableInfo->getTableFullName()); |
|
120 | - $tableInfo = $from; |
|
116 | + $gateway=$matchesRecord->getRecordGateway(); |
|
117 | + $recordTableInfo=$gateway->getRecordTableInfo($matchesRecord); |
|
118 | + $matchingTableName=strtolower($recordTableInfo->getTableName()); |
|
119 | + $matchingFullTableName=strtolower($recordTableInfo->getTableFullName()); |
|
120 | + $tableInfo=$from; |
|
121 | 121 | if($from instanceof TActiveRecord) |
122 | - $tableInfo = $gateway->getRecordTableInfo($from); |
|
122 | + $tableInfo=$gateway->getRecordTableInfo($from); |
|
123 | 123 | //find first non-empty FK |
124 | 124 | foreach($tableInfo->getForeignKeys() as $fkeys) |
125 | 125 | { |
126 | - $fkTable = strtolower($fkeys['table']); |
|
127 | - if($fkTable === $matchingTableName || $fkTable === $matchingFullTableName) |
|
126 | + $fkTable=strtolower($fkeys['table']); |
|
127 | + if($fkTable===$matchingTableName || $fkTable===$matchingFullTableName) |
|
128 | 128 | { |
129 | - $hasFkField = !$loose && $this->getContext()->hasFkField(); |
|
130 | - $key = $hasFkField ? $this->getFkFields($fkeys['keys']) : $fkeys['keys']; |
|
129 | + $hasFkField=!$loose && $this->getContext()->hasFkField(); |
|
130 | + $key=$hasFkField ? $this->getFkFields($fkeys['keys']) : $fkeys['keys']; |
|
131 | 131 | if(!empty($key)) |
132 | 132 | return $key; |
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
136 | 136 | //none found |
137 | - $matching = $gateway->getRecordTableInfo($matchesRecord)->getTableFullName(); |
|
137 | + $matching=$gateway->getRecordTableInfo($matchesRecord)->getTableFullName(); |
|
138 | 138 | throw new TActiveRecordException('ar_relations_missing_fk', |
139 | 139 | $tableInfo->getTableFullName(), $matching); |
140 | 140 | } |
@@ -152,13 +152,13 @@ discard block |
||
152 | 152 | */ |
153 | 153 | private function getFkFields($fkeys) |
154 | 154 | { |
155 | - $matching = []; |
|
155 | + $matching=[]; |
|
156 | 156 | preg_match_all('/\s*(\S+\.)?([\w-]+)\s*/', $this->getContext()->getFkField(), $matching); |
157 | - $fields = []; |
|
157 | + $fields=[]; |
|
158 | 158 | foreach($fkeys as $fkName => $field) |
159 | 159 | { |
160 | 160 | if(in_array($fkName, $matching[2])) |
161 | - $fields[$fkName] = $field; |
|
161 | + $fields[$fkName]=$field; |
|
162 | 162 | } |
163 | 163 | return $fields; |
164 | 164 | } |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | */ |
171 | 171 | protected function getObjectHash($obj, $properties) |
172 | 172 | { |
173 | - $ids = []; |
|
173 | + $ids=[]; |
|
174 | 174 | foreach($properties as $property) |
175 | - $ids[] = is_object($obj) ? (string)$obj->getColumnValue($property) : (string)$obj[$property]; |
|
175 | + $ids[]=is_object($obj) ? (string) $obj->getColumnValue($property) : (string) $obj[$property]; |
|
176 | 176 | return serialize($ids); |
177 | 177 | } |
178 | 178 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | */ |
185 | 185 | protected function findForeignObjects($fields, $indexValues) |
186 | 186 | { |
187 | - $finder = $this->getContext()->getForeignRecordFinder(); |
|
187 | + $finder=$this->getContext()->getForeignRecordFinder(); |
|
188 | 188 | return $finder->findAllByIndex($this->_criteria, $fields, $indexValues); |
189 | 189 | } |
190 | 190 | |
@@ -197,14 +197,14 @@ discard block |
||
197 | 197 | protected function getIndexValues($keys, $results) |
198 | 198 | { |
199 | 199 | if(!is_array($results) && !$results instanceof \ArrayAccess) |
200 | - $results = [$results]; |
|
201 | - $values = []; |
|
200 | + $results=[$results]; |
|
201 | + $values=[]; |
|
202 | 202 | foreach($results as $result) |
203 | 203 | { |
204 | - $value = []; |
|
204 | + $value=[]; |
|
205 | 205 | foreach($keys as $name) |
206 | - $value[] = $result->getColumnValue($name); |
|
207 | - $values[] = $value; |
|
206 | + $value[]=$result->getColumnValue($name); |
|
207 | + $values[]=$value; |
|
208 | 208 | } |
209 | 209 | return $values; |
210 | 210 | } |
@@ -218,9 +218,9 @@ discard block |
||
218 | 218 | */ |
219 | 219 | protected function populateResult(&$results, $properties, &$fkObjects, $fields) |
220 | 220 | { |
221 | - $collections = []; |
|
221 | + $collections=[]; |
|
222 | 222 | foreach($fkObjects as $fkObject) |
223 | - $collections[$this->getObjectHash($fkObject, $fields)][] = $fkObject; |
|
223 | + $collections[$this->getObjectHash($fkObject, $fields)][]=$fkObject; |
|
224 | 224 | $this->setResultCollection($results, $collections, $properties); |
225 | 225 | } |
226 | 226 | |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | { |
235 | 235 | if(is_array($results) || $results instanceof \ArrayAccess) |
236 | 236 | { |
237 | - for($i = 0,$k = count($results);$i < $k;$i++) |
|
237 | + for($i=0, $k=count($results); $i < $k; $i++) |
|
238 | 238 | $this->setObjectProperty($results[$i], $properties, $collections); |
239 | 239 | } |
240 | 240 | else |
@@ -249,9 +249,9 @@ discard block |
||
249 | 249 | */ |
250 | 250 | protected function setObjectProperty($source, $properties, &$collections) |
251 | 251 | { |
252 | - $hash = $this->getObjectHash($source, $properties); |
|
253 | - $prop = $this->getContext()->getProperty(); |
|
254 | - $source->$prop = isset($collections[$hash]) ? $collections[$hash] : []; |
|
252 | + $hash=$this->getObjectHash($source, $properties); |
|
253 | + $prop=$this->getContext()->getProperty(); |
|
254 | + $source->$prop=isset($collections[$hash]) ? $collections[$hash] : []; |
|
255 | 255 | } |
256 | 256 | } |
257 | 257 |
@@ -83,10 +83,10 @@ discard block |
||
83 | 83 | if($validArray || $results instanceof \ArrayAccess || $results instanceof TActiveRecord) |
84 | 84 | { |
85 | 85 | $this->collectForeignObjects($results); |
86 | - while($obj = array_pop($stack)) |
|
87 | - $obj->collectForeignObjects($results); |
|
88 | - } |
|
89 | - elseif($results instanceof TActiveRecordRelation) |
|
86 | + while($obj = array_pop($stack)) { |
|
87 | + $obj->collectForeignObjects($results); |
|
88 | + } |
|
89 | + } elseif($results instanceof TActiveRecordRelation) |
|
90 | 90 | $stack[] = $this; //call it later |
91 | 91 | elseif($results === null || !$validArray) |
92 | 92 | $stack = []; |
@@ -236,8 +236,7 @@ discard block |
||
236 | 236 | { |
237 | 237 | for($i = 0,$k = count($results);$i < $k;$i++) |
238 | 238 | $this->setObjectProperty($results[$i], $properties, $collections); |
239 | - } |
|
240 | - else |
|
239 | + } else |
|
241 | 240 | $this->setObjectProperty($results, $properties, $collections); |
242 | 241 | } |
243 | 242 |
@@ -66,6 +66,9 @@ |
||
66 | 66 | return $control; |
67 | 67 | } |
68 | 68 | |
69 | + /** |
|
70 | + * @return string |
|
71 | + */ |
|
69 | 72 | protected function getDefaultControlValue($container, $column, $record) |
70 | 73 | { |
71 | 74 | $control = $container->findControl(self::DEFAULT_ID); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | { |
35 | 35 | $control->setID(self::DEFAULT_ID); |
36 | 36 | $control->setEnabled($this->getIsEnabled($column, $record)); |
37 | - $container->Controls[] = $control; |
|
37 | + $container->Controls[]=$control; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | protected function setNotNullProperty($container, $control, $column, $record) |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | |
47 | 47 | protected function createBooleanControl($container, $column, $record) |
48 | 48 | { |
49 | - $value = $this->getRecordPropertyValue($column, $record); |
|
50 | - $control = new TCheckBox(); |
|
49 | + $value=$this->getRecordPropertyValue($column, $record); |
|
50 | + $control=new TCheckBox(); |
|
51 | 51 | $control->setChecked(TPropertyValue::ensureBoolean($value)); |
52 | 52 | $control->setCssClass('boolean-checkbox'); |
53 | 53 | $this->setDefaultProperty($container, $control, $column, $record); |
@@ -56,11 +56,11 @@ discard block |
||
56 | 56 | |
57 | 57 | protected function createDefaultControl($container, $column, $record) |
58 | 58 | { |
59 | - $value = $this->getRecordPropertyValue($column, $record); |
|
60 | - $control = new TTextBox(); |
|
59 | + $value=$this->getRecordPropertyValue($column, $record); |
|
60 | + $control=new TTextBox(); |
|
61 | 61 | $control->setText($value); |
62 | 62 | $control->setCssClass('default-textbox scaffold_input'); |
63 | - if(($len = $column->getColumnSize()) !== null) |
|
63 | + if(($len=$column->getColumnSize())!==null) |
|
64 | 64 | $control->setMaxLength($len); |
65 | 65 | $this->setNotNullProperty($container, $control, $column, $record); |
66 | 66 | return $control; |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | protected function getDefaultControlValue($container, $column, $record) |
70 | 70 | { |
71 | - $control = $container->findControl(self::DEFAULT_ID); |
|
71 | + $control=$container->findControl(self::DEFAULT_ID); |
|
72 | 72 | if($control instanceof TCheckBox) |
73 | 73 | return $control->getChecked(); |
74 | 74 | elseif($control instanceof TControl) |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | |
78 | 78 | protected function createMultiLineControl($container, $column, $record) |
79 | 79 | { |
80 | - $value = $this->getRecordPropertyValue($column, $record); |
|
81 | - $control = new TTextBox(); |
|
80 | + $value=$this->getRecordPropertyValue($column, $record); |
|
81 | + $control=new TTextBox(); |
|
82 | 82 | $control->setText($value); |
83 | 83 | $control->setTextMode(TTextBoxMode::MultiLine); |
84 | 84 | $control->setCssClass('multiline-textbox scaffold_input'); |
@@ -88,13 +88,13 @@ discard block |
||
88 | 88 | |
89 | 89 | protected function createYearControl($container, $column, $record) |
90 | 90 | { |
91 | - $value = $this->getRecordPropertyValue($column, $record); |
|
92 | - $control = new TDropDownList(); |
|
93 | - $years = []; |
|
94 | - $current = intval(@date('Y')); |
|
95 | - $from = $current - 10; $to = $current + 10; |
|
96 | - for($i = $from; $i <= $to; $i++) |
|
97 | - $years[$i] = $i; |
|
91 | + $value=$this->getRecordPropertyValue($column, $record); |
|
92 | + $control=new TDropDownList(); |
|
93 | + $years=[]; |
|
94 | + $current=intval(@date('Y')); |
|
95 | + $from=$current - 10; $to=$current + 10; |
|
96 | + for($i=$from; $i <= $to; $i++) |
|
97 | + $years[$i]=$i; |
|
98 | 98 | $control->setDataSource($years); |
99 | 99 | $control->setSelectedValue(empty($value) ? $current : $value); |
100 | 100 | $control->setCssClass('year-dropdown'); |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | |
105 | 105 | protected function createIntegerControl($container, $column, $record) |
106 | 106 | { |
107 | - $control = $this->createDefaultControl($container, $column, $record); |
|
108 | - $val = $this->createTypeValidator($container, $column, $record); |
|
107 | + $control=$this->createDefaultControl($container, $column, $record); |
|
108 | + $val=$this->createTypeValidator($container, $column, $record); |
|
109 | 109 | $val->setDataType(TValidationDataType::Integer); |
110 | 110 | $val->setErrorMessage('Please entery an integer.'); |
111 | 111 | return $control; |
@@ -113,111 +113,111 @@ discard block |
||
113 | 113 | |
114 | 114 | protected function createFloatControl($container, $column, $record) |
115 | 115 | { |
116 | - $control = $this->createDefaultControl($container, $column, $record); |
|
117 | - $val = $this->createTypeValidator($container, $column, $record); |
|
116 | + $control=$this->createDefaultControl($container, $column, $record); |
|
117 | + $val=$this->createTypeValidator($container, $column, $record); |
|
118 | 118 | $val->setDataType(TValidationDataType::Float); |
119 | 119 | $val->setErrorMessage('Please entery a decimal number.'); |
120 | - if(($max = $column->getMaxiumNumericConstraint()) !== null) |
|
120 | + if(($max=$column->getMaxiumNumericConstraint())!==null) |
|
121 | 121 | { |
122 | - $val = $this->createRangeValidator($container, $column, $record); |
|
122 | + $val=$this->createRangeValidator($container, $column, $record); |
|
123 | 123 | $val->setDataType(TValidationDataType::Float); |
124 | 124 | $val->setMaxValue($max); |
125 | 125 | $val->setStrictComparison(true); |
126 | - $val->setErrorMessage('Please entery a decimal number strictly less than ' . $max . '.'); |
|
126 | + $val->setErrorMessage('Please entery a decimal number strictly less than '.$max.'.'); |
|
127 | 127 | } |
128 | 128 | return $control; |
129 | 129 | } |
130 | 130 | |
131 | 131 | protected function createRequiredValidator($container, $column, $record) |
132 | 132 | { |
133 | - $val = new TRequiredFieldValidator(); |
|
133 | + $val=new TRequiredFieldValidator(); |
|
134 | 134 | $val->setErrorMessage('*'); |
135 | 135 | $val->setControlCssClass('required-input'); |
136 | 136 | $val->setCssClass('required'); |
137 | 137 | $val->setControlToValidate(self::DEFAULT_ID); |
138 | 138 | $val->setValidationGroup($this->getParent()->getValidationGroup()); |
139 | 139 | $val->setDisplay(TValidatorDisplayStyle::Dynamic); |
140 | - $container->Controls[] = $val; |
|
140 | + $container->Controls[]=$val; |
|
141 | 141 | return $val; |
142 | 142 | } |
143 | 143 | |
144 | 144 | protected function createTypeValidator($container, $column, $record) |
145 | 145 | { |
146 | - $val = new TDataTypeValidator(); |
|
146 | + $val=new TDataTypeValidator(); |
|
147 | 147 | $val->setControlCssClass('required-input2'); |
148 | 148 | $val->setCssClass('required'); |
149 | 149 | $val->setControlToValidate(self::DEFAULT_ID); |
150 | 150 | $val->setValidationGroup($this->getParent()->getValidationGroup()); |
151 | 151 | $val->setDisplay(TValidatorDisplayStyle::Dynamic); |
152 | - $container->Controls[] = $val; |
|
152 | + $container->Controls[]=$val; |
|
153 | 153 | return $val; |
154 | 154 | } |
155 | 155 | |
156 | 156 | protected function createRangeValidator($container, $column, $record) |
157 | 157 | { |
158 | - $val = new TRangeValidator(); |
|
158 | + $val=new TRangeValidator(); |
|
159 | 159 | $val->setControlCssClass('required-input3'); |
160 | 160 | $val->setCssClass('required'); |
161 | 161 | $val->setControlToValidate(self::DEFAULT_ID); |
162 | 162 | $val->setValidationGroup($this->getParent()->getValidationGroup()); |
163 | 163 | $val->setDisplay(TValidatorDisplayStyle::Dynamic); |
164 | - $container->Controls[] = $val; |
|
164 | + $container->Controls[]=$val; |
|
165 | 165 | return $val; |
166 | 166 | } |
167 | 167 | |
168 | 168 | protected function createTimeControl($container, $column, $record) |
169 | 169 | { |
170 | - $value = $this->getRecordPropertyValue($column, $record); |
|
171 | - $hours = []; |
|
172 | - for($i = 0;$i < 24;$i++) $hours[] = str_pad($i, 2, '0', STR_PAD_LEFT); |
|
173 | - $mins = []; |
|
174 | - for($i = 0;$i < 60;$i++) $mins[] = str_pad($i, 2, '0', STR_PAD_LEFT); |
|
175 | - $hour = intval(@date('H')); |
|
176 | - $min = intval(@date('i')); |
|
177 | - $sec = intval(@date('s')); |
|
170 | + $value=$this->getRecordPropertyValue($column, $record); |
|
171 | + $hours=[]; |
|
172 | + for($i=0; $i < 24; $i++) $hours[]=str_pad($i, 2, '0', STR_PAD_LEFT); |
|
173 | + $mins=[]; |
|
174 | + for($i=0; $i < 60; $i++) $mins[]=str_pad($i, 2, '0', STR_PAD_LEFT); |
|
175 | + $hour=intval(@date('H')); |
|
176 | + $min=intval(@date('i')); |
|
177 | + $sec=intval(@date('s')); |
|
178 | 178 | if(!empty($value)) |
179 | 179 | { |
180 | - $match = []; |
|
180 | + $match=[]; |
|
181 | 181 | if(preg_match('/(\d+):(\d+):?(\d+)?/', $value, $match)) |
182 | 182 | { |
183 | - $hour = $match[1]; |
|
184 | - $min = $match[2]; |
|
183 | + $hour=$match[1]; |
|
184 | + $min=$match[2]; |
|
185 | 185 | if(isset($match[3])) |
186 | - $sec = $match[3]; |
|
186 | + $sec=$match[3]; |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
190 | - $hcontrol = new TDropDownList(); |
|
190 | + $hcontrol=new TDropDownList(); |
|
191 | 191 | $hcontrol->setDataSource($hours); |
192 | 192 | $hcontrol->setID(self::DEFAULT_ID); |
193 | 193 | $hcontrol->dataBind(); |
194 | 194 | $hcontrol->setSelectedValue(intval($hour)); |
195 | - $container->Controls[] = $hcontrol; |
|
196 | - $container->Controls[] = ' : '; |
|
195 | + $container->Controls[]=$hcontrol; |
|
196 | + $container->Controls[]=' : '; |
|
197 | 197 | |
198 | - $mcontrol = new TDropDownList(); |
|
198 | + $mcontrol=new TDropDownList(); |
|
199 | 199 | $mcontrol->setDataSource($mins); |
200 | 200 | $mcontrol->dataBind(); |
201 | 201 | $mcontrol->setID('scaffold_time_min'); |
202 | 202 | $mcontrol->setSelectedValue(intval($min)); |
203 | - $container->Controls[] = $mcontrol; |
|
204 | - $container->Controls[] = ' : '; |
|
203 | + $container->Controls[]=$mcontrol; |
|
204 | + $container->Controls[]=' : '; |
|
205 | 205 | |
206 | - $scontrol = new TDropDownList(); |
|
206 | + $scontrol=new TDropDownList(); |
|
207 | 207 | $scontrol->setDataSource($mins); |
208 | 208 | $scontrol->dataBind(); |
209 | 209 | $scontrol->setID('scaffold_time_sec'); |
210 | 210 | $scontrol->setSelectedValue(intval($sec)); |
211 | - $container->Controls[] = $scontrol; |
|
211 | + $container->Controls[]=$scontrol; |
|
212 | 212 | |
213 | - return [$hcontrol,$mcontrol,$scontrol]; |
|
213 | + return [$hcontrol, $mcontrol, $scontrol]; |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | |
217 | 217 | protected function createDateControl($container, $column, $record) |
218 | 218 | { |
219 | - $value = $this->getRecordPropertyValue($column, $record); |
|
220 | - $control = new TDatePicker(); |
|
219 | + $value=$this->getRecordPropertyValue($column, $record); |
|
220 | + $control=new TDatePicker(); |
|
221 | 221 | $control->setFromYear(1900); |
222 | 222 | $control->setInputMode(TDatePickerInputMode::DropDownList); |
223 | 223 | $control->setDateFormat('yyyy-MM-dd'); |
@@ -230,13 +230,13 @@ discard block |
||
230 | 230 | |
231 | 231 | protected function createDateTimeControl($container, $column, $record) |
232 | 232 | { |
233 | - $value = $this->getRecordPropertyValue($column, $record); |
|
234 | - $control = $this->createDateControl($container, $column, $record); |
|
235 | - $container->Controls[] = ' @ '; |
|
236 | - $time = $this->createTimeControl($container, $column, $record); |
|
233 | + $value=$this->getRecordPropertyValue($column, $record); |
|
234 | + $control=$this->createDateControl($container, $column, $record); |
|
235 | + $container->Controls[]=' @ '; |
|
236 | + $time=$this->createTimeControl($container, $column, $record); |
|
237 | 237 | if(!empty($value)) |
238 | 238 | { |
239 | - $match = []; |
|
239 | + $match=[]; |
|
240 | 240 | if(preg_match('/(\d+):(\d+):?(\d+)?/', substr($value, 11), $match)) |
241 | 241 | { |
242 | 242 | $time[0]->setSelectedValue(intval($match[1])); |
@@ -251,27 +251,27 @@ discard block |
||
251 | 251 | |
252 | 252 | protected function getDateTimeValue($container, $column, $record) |
253 | 253 | { |
254 | - $date = $container->findControl(self::DEFAULT_ID)->getDate(); |
|
255 | - $hour = $container->findControl('scaffold_time_hour')->getSelectedValue(); |
|
256 | - $mins = $container->findControl('scaffold_time_min')->getSelectedValue(); |
|
257 | - $secs = $container->findControl('scaffold_time_sec')->getSelectedValue(); |
|
254 | + $date=$container->findControl(self::DEFAULT_ID)->getDate(); |
|
255 | + $hour=$container->findControl('scaffold_time_hour')->getSelectedValue(); |
|
256 | + $mins=$container->findControl('scaffold_time_min')->getSelectedValue(); |
|
257 | + $secs=$container->findControl('scaffold_time_sec')->getSelectedValue(); |
|
258 | 258 | return "{$date} {$hour}:{$mins}:{$secs}"; |
259 | 259 | } |
260 | 260 | |
261 | 261 | protected function getTimeValue($container, $column, $record) |
262 | 262 | { |
263 | - $hour = $container->findControl(self::DEFAULT_ID)->getSelectedValue(); |
|
264 | - $mins = $container->findControl('scaffold_time_min')->getSelectedValue(); |
|
265 | - $secs = $container->findControl('scaffold_time_sec')->getSelectedValue(); |
|
263 | + $hour=$container->findControl(self::DEFAULT_ID)->getSelectedValue(); |
|
264 | + $mins=$container->findControl('scaffold_time_min')->getSelectedValue(); |
|
265 | + $secs=$container->findControl('scaffold_time_sec')->getSelectedValue(); |
|
266 | 266 | return "{$hour}:{$mins}:{$secs}"; |
267 | 267 | } |
268 | 268 | |
269 | 269 | protected function createSetControl($container, $column, $record) |
270 | 270 | { |
271 | - $value = $this->getRecordPropertyValue($column, $record); |
|
272 | - $selectedValues = preg_split('/\s*,\s*/', $value); |
|
273 | - $control = new TCheckBoxList(); |
|
274 | - $values = $column->getDbTypeValues(); |
|
271 | + $value=$this->getRecordPropertyValue($column, $record); |
|
272 | + $selectedValues=preg_split('/\s*,\s*/', $value); |
|
273 | + $control=new TCheckBoxList(); |
|
274 | + $values=$column->getDbTypeValues(); |
|
275 | 275 | $control->setDataSource($values); |
276 | 276 | $control->dataBind(); |
277 | 277 | $control->setSelectedIndices($this->getMatchingIndices($values, $selectedValues)); |
@@ -283,24 +283,24 @@ discard block |
||
283 | 283 | |
284 | 284 | protected function getMatchingIndices($checks, $values) |
285 | 285 | { |
286 | - $index = []; |
|
287 | - for($i = 0, $k = count($checks); $i < $k; $i++) |
|
286 | + $index=[]; |
|
287 | + for($i=0, $k=count($checks); $i < $k; $i++) |
|
288 | 288 | { |
289 | 289 | if(in_array($checks[$i], $values)) |
290 | - $index[] = $i; |
|
290 | + $index[]=$i; |
|
291 | 291 | } |
292 | 292 | return $index; |
293 | 293 | } |
294 | 294 | |
295 | 295 | protected function createEnumControl($container, $column, $record) |
296 | 296 | { |
297 | - $value = $this->getRecordPropertyValue($column, $record); |
|
298 | - $selectedValues = preg_split('/\s*,\s*/', $value); |
|
299 | - $control = new TRadioButtonList(); |
|
300 | - $values = $column->getDbTypeValues(); |
|
297 | + $value=$this->getRecordPropertyValue($column, $record); |
|
298 | + $selectedValues=preg_split('/\s*,\s*/', $value); |
|
299 | + $control=new TRadioButtonList(); |
|
300 | + $values=$column->getDbTypeValues(); |
|
301 | 301 | $control->setDataSource($values); |
302 | 302 | $control->dataBind(); |
303 | - $index = $this->getMatchingIndices($values, $selectedValues); |
|
303 | + $index=$this->getMatchingIndices($values, $selectedValues); |
|
304 | 304 | if(count($index) > 0) |
305 | 305 | $control->setSelectedIndex($index[0]); |
306 | 306 | $control->setID(self::DEFAULT_ID); |
@@ -311,11 +311,11 @@ discard block |
||
311 | 311 | |
312 | 312 | protected function getSetValue($container, $column, $record) |
313 | 313 | { |
314 | - $value = []; |
|
314 | + $value=[]; |
|
315 | 315 | foreach($container->findControl(self::DEFAULT_ID)->getItems() as $item) |
316 | 316 | { |
317 | 317 | if($item->getSelected()) |
318 | - $value[] = $item->getText(); |
|
318 | + $value[]=$item->getText(); |
|
319 | 319 | } |
320 | 320 | return implode(',', $value); |
321 | 321 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | /** |
150 | 150 | * @param string table schema name |
151 | 151 | * @param string table name. |
152 | - * @return boolean true if the table is a view. |
|
152 | + * @return integer true if the table is a view. |
|
153 | 153 | */ |
154 | 154 | protected function getIsView($schemaName, $tableName) |
155 | 155 | { |
@@ -171,6 +171,7 @@ discard block |
||
171 | 171 | /** |
172 | 172 | * @param TOracleTableInfo table information. |
173 | 173 | * @param array column information. |
174 | + * @param TOracleTableInfo $tableInfo |
|
174 | 175 | */ |
175 | 176 | protected function processColumn($tableInfo, $col) |
176 | 177 | { |
@@ -326,6 +327,7 @@ discard block |
||
326 | 327 | /** |
327 | 328 | * @param string column name. |
328 | 329 | * @param TOracleTableInfo table information. |
330 | + * @param string $columnId |
|
329 | 331 | * @return boolean true if column is a foreign key. |
330 | 332 | */ |
331 | 333 | protected function isForeignKeyColumn($columnId, $tableInfo) |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | class TOracleMetaData extends TDbMetaData |
31 | 31 | { |
32 | - private $_defaultSchema = 'system'; |
|
32 | + private $_defaultSchema='system'; |
|
33 | 33 | |
34 | 34 | |
35 | 35 | /** |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function setDefaultSchema($schema) |
47 | 47 | { |
48 | - $this->_defaultSchema = $schema; |
|
48 | + $this->_defaultSchema=$schema; |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -62,10 +62,10 @@ discard block |
||
62 | 62 | */ |
63 | 63 | protected function getSchemaTableName($table) |
64 | 64 | { |
65 | - if(count($parts = explode('.', str_replace('"', '', $table))) > 1) |
|
65 | + if(count($parts=explode('.', str_replace('"', '', $table))) > 1) |
|
66 | 66 | return [$parts[0], $parts[1]]; |
67 | 67 | else |
68 | - return [$this->getDefaultSchema(),$parts[0]]; |
|
68 | + return [$this->getDefaultSchema(), $parts[0]]; |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -75,12 +75,12 @@ discard block |
||
75 | 75 | */ |
76 | 76 | protected function createTableInfo($table) |
77 | 77 | { |
78 | - list($schemaName, $tableName) = $this->getSchemaTableName($table); |
|
78 | + list($schemaName, $tableName)=$this->getSchemaTableName($table); |
|
79 | 79 | |
80 | 80 | // This query is made much more complex by the addition of the 'attisserial' field. |
81 | 81 | // The subquery to get that field checks to see if there is an internally dependent |
82 | 82 | // sequence on the field. |
83 | - $sql = |
|
83 | + $sql= |
|
84 | 84 | <<<EOD |
85 | 85 | SELECT |
86 | 86 | a.COLUMN_ID, |
@@ -100,17 +100,17 @@ discard block |
||
100 | 100 | EOD; |
101 | 101 | $this->getDbConnection()->setActive(true); |
102 | 102 | $this->getDbConnection()->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
103 | - $command = $this->getDbConnection()->createCommand($sql); |
|
103 | + $command=$this->getDbConnection()->createCommand($sql); |
|
104 | 104 | //$command->bindValue(':table', $tableName); |
105 | 105 | //$command->bindValue(':schema', $schemaName); |
106 | - $tableInfo = $this->createNewTableInfo($schemaName, $tableName); |
|
107 | - $index = 0; |
|
106 | + $tableInfo=$this->createNewTableInfo($schemaName, $tableName); |
|
107 | + $index=0; |
|
108 | 108 | foreach($command->query() as $col) |
109 | 109 | { |
110 | - $col['index'] = $index++; |
|
110 | + $col['index']=$index++; |
|
111 | 111 | $this->processColumn($tableInfo, $col); |
112 | 112 | } |
113 | - if($index === 0) |
|
113 | + if($index===0) |
|
114 | 114 | throw new TDbException('dbmetadata_invalid_table_view', $table); |
115 | 115 | return $tableInfo; |
116 | 116 | } |
@@ -122,12 +122,12 @@ discard block |
||
122 | 122 | */ |
123 | 123 | protected function createNewTableInfo($schemaName, $tableName) |
124 | 124 | { |
125 | - $info['SchemaName'] = $this->assertIdentifier($schemaName); |
|
126 | - $info['TableName'] = $this->assertIdentifier($tableName); |
|
127 | - $info['IsView'] = false; |
|
128 | - if($this->getIsView($schemaName, $tableName)) $info['IsView'] = true; |
|
129 | - list($primary, $foreign) = $this->getConstraintKeys($schemaName, $tableName); |
|
130 | - $class = $this->getTableInfoClass(); |
|
125 | + $info['SchemaName']=$this->assertIdentifier($schemaName); |
|
126 | + $info['TableName']=$this->assertIdentifier($tableName); |
|
127 | + $info['IsView']=false; |
|
128 | + if($this->getIsView($schemaName, $tableName)) $info['IsView']=true; |
|
129 | + list($primary, $foreign)=$this->getConstraintKeys($schemaName, $tableName); |
|
130 | + $class=$this->getTableInfoClass(); |
|
131 | 131 | return new $class($info, $primary, $foreign); |
132 | 132 | } |
133 | 133 | |
@@ -138,9 +138,9 @@ discard block |
||
138 | 138 | */ |
139 | 139 | protected function assertIdentifier($name) |
140 | 140 | { |
141 | - if(strpos($name, '"') !== false) |
|
141 | + if(strpos($name, '"')!==false) |
|
142 | 142 | { |
143 | - $ref = 'http://www.oracle.com'; |
|
143 | + $ref='http://www.oracle.com'; |
|
144 | 144 | throw new TDbException('dbcommon_invalid_identifier_name', $name, $ref); |
145 | 145 | } |
146 | 146 | return $name; |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | protected function getIsView($schemaName, $tableName) |
155 | 155 | { |
156 | 156 | $this->getDbConnection()->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
157 | - $sql = |
|
157 | + $sql= |
|
158 | 158 | <<<EOD |
159 | 159 | select OBJECT_TYPE |
160 | 160 | from ALL_OBJECTS |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | and OWNER = '{$schemaName}' |
163 | 163 | EOD; |
164 | 164 | $this->getDbConnection()->setActive(true); |
165 | - $command = $this->getDbConnection()->createCommand($sql); |
|
165 | + $command=$this->getDbConnection()->createCommand($sql); |
|
166 | 166 | //$command->bindValue(':schema',$schemaName); |
167 | 167 | //$command->bindValue(':table', $tableName); |
168 | - return intval($command->queryScalar() === 'VIEW'); |
|
168 | + return intval($command->queryScalar()==='VIEW'); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -174,17 +174,17 @@ discard block |
||
174 | 174 | */ |
175 | 175 | protected function processColumn($tableInfo, $col) |
176 | 176 | { |
177 | - $columnId = strtolower($col['attname']); //use column name as column Id |
|
177 | + $columnId=strtolower($col['attname']); //use column name as column Id |
|
178 | 178 | |
179 | 179 | //$info['ColumnName'] = '"'.$columnId.'"'; //quote the column names! |
180 | - $info['ColumnName'] = $columnId; //NOT quote the column names! |
|
181 | - $info['ColumnId'] = $columnId; |
|
182 | - $info['ColumnIndex'] = $col['index']; |
|
183 | - if(! (bool)$col['attnotnull']) $info['AllowNull'] = true; |
|
184 | - if(in_array($columnId, $tableInfo->getPrimaryKeys())) $info['IsPrimaryKey'] = true; |
|
185 | - if($this->isForeignKeyColumn($columnId, $tableInfo)) $info['IsForeignKey'] = true; |
|
186 | - if((int)$col['atttypmod'] > 0) $info['ColumnSize'] = $col['atttypmod']; // - 4; |
|
187 | - if((bool)$col['atthasdef']) $info['DefaultValue'] = $col['adsrc']; |
|
180 | + $info['ColumnName']=$columnId; //NOT quote the column names! |
|
181 | + $info['ColumnId']=$columnId; |
|
182 | + $info['ColumnIndex']=$col['index']; |
|
183 | + if(!(bool) $col['attnotnull']) $info['AllowNull']=true; |
|
184 | + if(in_array($columnId, $tableInfo->getPrimaryKeys())) $info['IsPrimaryKey']=true; |
|
185 | + if($this->isForeignKeyColumn($columnId, $tableInfo)) $info['IsForeignKey']=true; |
|
186 | + if((int) $col['atttypmod'] > 0) $info['ColumnSize']=$col['atttypmod']; // - 4; |
|
187 | + if((bool) $col['atthasdef']) $info['DefaultValue']=$col['adsrc']; |
|
188 | 188 | // |
189 | 189 | // For a while Oracle Tables has no associated AutoIncrement Triggers |
190 | 190 | // |
@@ -198,22 +198,22 @@ discard block |
||
198 | 198 | } |
199 | 199 | } |
200 | 200 | */ |
201 | - $matches = []; |
|
201 | + $matches=[]; |
|
202 | 202 | if(preg_match('/\((\d+)(?:,(\d+))?+\)/', $col['type'], $matches)) |
203 | 203 | { |
204 | - $info['DbType'] = preg_replace('/\(\d+(?:,\d+)?\)/', '', $col['type']); |
|
204 | + $info['DbType']=preg_replace('/\(\d+(?:,\d+)?\)/', '', $col['type']); |
|
205 | 205 | if($this->isPrecisionType($info['DbType'])) |
206 | 206 | { |
207 | - $info['NumericPrecision'] = intval($matches[1]); |
|
207 | + $info['NumericPrecision']=intval($matches[1]); |
|
208 | 208 | if(count($matches) > 2) |
209 | - $info['NumericScale'] = intval($matches[2]); |
|
209 | + $info['NumericScale']=intval($matches[2]); |
|
210 | 210 | } |
211 | 211 | else |
212 | - $info['ColumnSize'] = intval($matches[1]); |
|
212 | + $info['ColumnSize']=intval($matches[1]); |
|
213 | 213 | } |
214 | 214 | else |
215 | - $info['DbType'] = $col['type']; |
|
216 | - $tableInfo->Columns[$columnId] = new TOracleTableColumn($info); |
|
215 | + $info['DbType']=$col['type']; |
|
216 | + $tableInfo->Columns[$columnId]=new TOracleTableColumn($info); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
@@ -221,13 +221,13 @@ discard block |
||
221 | 221 | */ |
222 | 222 | protected function getSequenceName($tableInfo, $src) |
223 | 223 | { |
224 | - $matches = []; |
|
224 | + $matches=[]; |
|
225 | 225 | if(preg_match('/nextval\([^\']*\'([^\']+)\'[^\)]*\)/i', $src, $matches)) |
226 | 226 | { |
227 | 227 | if(is_int(strpos($matches[1], '.'))) |
228 | 228 | return $matches[1]; |
229 | 229 | else |
230 | - return $tableInfo->getSchemaName() . '.' . $matches[1]; |
|
230 | + return $tableInfo->getSchemaName().'.'.$matches[1]; |
|
231 | 231 | } |
232 | 232 | } |
233 | 233 | |
@@ -236,8 +236,8 @@ discard block |
||
236 | 236 | */ |
237 | 237 | protected function isPrecisionType($type) |
238 | 238 | { |
239 | - $type = strtolower(trim($type)); |
|
240 | - return $type === 'number'; // || $type==='interval' || strpos($type, 'time')===0; |
|
239 | + $type=strtolower(trim($type)); |
|
240 | + return $type==='number'; // || $type==='interval' || strpos($type, 'time')===0; |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | /** |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | { |
251 | 251 | $this->getDbConnection()->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
252 | 252 | // select decode( a.CONSTRAINT_TYPE, 'P', 'PRIMARY KEY (', 'FOREIGN KEY (' )||b.COLUMN_NAME||')' as consrc, |
253 | - $sql = |
|
253 | + $sql= |
|
254 | 254 | <<<EOD |
255 | 255 | select b.COLUMN_NAME as consrc, |
256 | 256 | a.CONSTRAINT_TYPE as contype |
@@ -261,24 +261,24 @@ discard block |
||
261 | 261 | and a.CONSTRAINT_TYPE in ('P','R') |
262 | 262 | EOD; |
263 | 263 | $this->getDbConnection()->setActive(true); |
264 | - $command = $this->getDbConnection()->createCommand($sql); |
|
264 | + $command=$this->getDbConnection()->createCommand($sql); |
|
265 | 265 | //$command->bindValue(':table', $tableName); |
266 | 266 | //$command->bindValue(':schema', $schemaName); |
267 | - $primary = []; |
|
268 | - $foreign = []; |
|
267 | + $primary=[]; |
|
268 | + $foreign=[]; |
|
269 | 269 | foreach($command->query() as $row) |
270 | 270 | { |
271 | 271 | switch(strtolower($row['contype'])) |
272 | 272 | { |
273 | 273 | case 'p': |
274 | - $primary = array_merge($primary, [strtolower($row['consrc'])]); |
|
274 | + $primary=array_merge($primary, [strtolower($row['consrc'])]); |
|
275 | 275 | /* |
276 | 276 | $arr = $this->getPrimaryKeys($row['consrc']); |
277 | 277 | $primary = array_merge( $primary, array(strtolower( $arr[0] )) ); |
278 | 278 | */ |
279 | 279 | break; |
280 | 280 | case 'r': |
281 | - $foreign = array_merge($foreign, [strtolower($row['consrc'])]); |
|
281 | + $foreign=array_merge($foreign, [strtolower($row['consrc'])]); |
|
282 | 282 | /* |
283 | 283 | // if(($fkey = $this->getForeignKeys($row['consrc']))!==null) |
284 | 284 | $fkey = $this->getForeignKeys( $row['consrc'] ); |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | break; |
288 | 288 | } |
289 | 289 | } |
290 | - return [$primary,$foreign]; |
|
290 | + return [$primary, $foreign]; |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | /** |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | */ |
298 | 298 | protected function getPrimaryKeys($src) |
299 | 299 | { |
300 | - $matches = []; |
|
300 | + $matches=[]; |
|
301 | 301 | if(preg_match('/PRIMARY\s+KEY\s+\(([^\)]+)\)/i', $src, $matches)) |
302 | 302 | return preg_split('/,\s+/', $matches[1]); |
303 | 303 | return []; |
@@ -310,15 +310,15 @@ discard block |
||
310 | 310 | */ |
311 | 311 | protected function getForeignKeys($src) |
312 | 312 | { |
313 | - $matches = []; |
|
314 | - $brackets = '\(([^\)]+)\)'; |
|
315 | - $find = "/FOREIGN\s+KEY\s+{$brackets}\s+REFERENCES\s+([^\(]+){$brackets}/i"; |
|
313 | + $matches=[]; |
|
314 | + $brackets='\(([^\)]+)\)'; |
|
315 | + $find="/FOREIGN\s+KEY\s+{$brackets}\s+REFERENCES\s+([^\(]+){$brackets}/i"; |
|
316 | 316 | if(preg_match($find, $src, $matches)) |
317 | 317 | { |
318 | - $keys = preg_split('/,\s+/', $matches[1]); |
|
319 | - $fkeys = []; |
|
318 | + $keys=preg_split('/,\s+/', $matches[1]); |
|
319 | + $fkeys=[]; |
|
320 | 320 | foreach(preg_split('/,\s+/', $matches[3]) as $i => $fkey) |
321 | - $fkeys[$keys[$i]] = $fkey; |
|
321 | + $fkeys[$keys[$i]]=$fkey; |
|
322 | 322 | return ['table' => str_replace('"', '', $matches[2]), 'keys' => $fkeys]; |
323 | 323 | } |
324 | 324 | } |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | { |
333 | 333 | foreach($tableInfo->getForeignKeys() as $fk) |
334 | 334 | { |
335 | - if($fk == $columnId) |
|
335 | + if($fk==$columnId) |
|
336 | 336 | //if(in_array($columnId, array_keys($fk['keys']))) |
337 | 337 | return true; |
338 | 338 | } |
@@ -345,33 +345,33 @@ discard block |
||
345 | 345 | * If not empty, the returned table names will be prefixed with the schema name. |
346 | 346 | * @return array all table names in the database. |
347 | 347 | */ |
348 | - public function findTableNames($schema = '') |
|
348 | + public function findTableNames($schema='') |
|
349 | 349 | { |
350 | - if($schema === '') |
|
350 | + if($schema==='') |
|
351 | 351 | { |
352 | - $sql = <<<EOD |
|
352 | + $sql=<<<EOD |
|
353 | 353 | SELECT table_name, '{$schema}' as table_schema FROM user_tables |
354 | 354 | EOD; |
355 | - $command = $this->getDbConnection()->createCommand($sql); |
|
355 | + $command=$this->getDbConnection()->createCommand($sql); |
|
356 | 356 | } |
357 | 357 | else |
358 | 358 | { |
359 | - $sql = <<<EOD |
|
359 | + $sql=<<<EOD |
|
360 | 360 | SELECT object_name as table_name, owner as table_schema FROM all_objects |
361 | 361 | WHERE object_type = 'TABLE' AND owner=:schema |
362 | 362 | EOD; |
363 | - $command = $this->getDbConnection()->createCommand($sql); |
|
363 | + $command=$this->getDbConnection()->createCommand($sql); |
|
364 | 364 | $command->bindParam(':schema', $schema); |
365 | 365 | } |
366 | 366 | |
367 | - $rows = $command->queryAll(); |
|
368 | - $names = []; |
|
367 | + $rows=$command->queryAll(); |
|
368 | + $names=[]; |
|
369 | 369 | foreach($rows as $row) |
370 | 370 | { |
371 | - if($schema === $this->getDefaultSchema() || $schema === '') |
|
372 | - $names[] = $row['TABLE_NAME']; |
|
371 | + if($schema===$this->getDefaultSchema() || $schema==='') |
|
372 | + $names[]=$row['TABLE_NAME']; |
|
373 | 373 | else |
374 | - $names[] = $row['TABLE_SCHEMA'] . '.' . $row['TABLE_NAME']; |
|
374 | + $names[]=$row['TABLE_SCHEMA'].'.'.$row['TABLE_NAME']; |
|
375 | 375 | } |
376 | 376 | return $names; |
377 | 377 | } |
@@ -207,11 +207,9 @@ discard block |
||
207 | 207 | $info['NumericPrecision'] = intval($matches[1]); |
208 | 208 | if(count($matches) > 2) |
209 | 209 | $info['NumericScale'] = intval($matches[2]); |
210 | - } |
|
211 | - else |
|
210 | + } else |
|
212 | 211 | $info['ColumnSize'] = intval($matches[1]); |
213 | - } |
|
214 | - else |
|
212 | + } else |
|
215 | 213 | $info['DbType'] = $col['type']; |
216 | 214 | $tableInfo->Columns[$columnId] = new TOracleTableColumn($info); |
217 | 215 | } |
@@ -353,8 +351,7 @@ discard block |
||
353 | 351 | SELECT table_name, '{$schema}' as table_schema FROM user_tables |
354 | 352 | EOD; |
355 | 353 | $command = $this->getDbConnection()->createCommand($sql); |
356 | - } |
|
357 | - else |
|
354 | + } else |
|
358 | 355 | { |
359 | 356 | $sql = <<<EOD |
360 | 357 | SELECT object_name as table_name, owner as table_schema FROM all_objects |
@@ -255,6 +255,7 @@ discard block |
||
255 | 255 | * in the sql text. Extracts inline parameter maps. |
256 | 256 | * @param TSqlMapStatement mapped statement. |
257 | 257 | * @param SimpleXmlElement statement node. |
258 | + * @param TSqlMapStatement $statement |
|
258 | 259 | */ |
259 | 260 | protected function processSqlStatement($statement, $node) |
260 | 261 | { |
@@ -278,6 +279,7 @@ discard block |
||
278 | 279 | * @param TSqlMapStatement statement object. |
279 | 280 | * @param string sql text |
280 | 281 | * @param SimpleXmlElement statement node. |
282 | + * @param string $sqlStatement |
|
281 | 283 | */ |
282 | 284 | protected function applyInlineParameterMap($statement, $sqlStatement, $node) |
283 | 285 | { |
@@ -375,6 +377,7 @@ discard block |
||
375 | 377 | /** |
376 | 378 | * Load the selectKey statement from xml mapping. |
377 | 379 | * @param SimpleXmlElement selectkey node |
380 | + * @param TSqlMapInsert $insert |
|
378 | 381 | */ |
379 | 382 | protected function loadSelectKeyTag($insert, $node) |
380 | 383 | { |
@@ -465,6 +468,7 @@ discard block |
||
465 | 468 | * Load the flush interval |
466 | 469 | * @param TSqlMapCacheModel cache model |
467 | 470 | * @param SimpleXmlElement cache node |
471 | + * @param TSqlMapCacheModel $cacheModel |
|
468 | 472 | */ |
469 | 473 | protected function loadFlushInterval($cacheModel, $node) |
470 | 474 | { |
@@ -500,6 +504,7 @@ discard block |
||
500 | 504 | * @param TSqlMapCacheModel cache model |
501 | 505 | * @param SimpleXmlElement parent node. |
502 | 506 | * @param SimpleXmlElement flush node. |
507 | + * @param TSqlMapCacheModel $cacheModel |
|
503 | 508 | */ |
504 | 509 | protected function loadFlushOnCache($cacheModel, $parent, $node) |
505 | 510 | { |
@@ -40,25 +40,25 @@ discard block |
||
40 | 40 | |
41 | 41 | private $_document; |
42 | 42 | |
43 | - private $_FlushOnExecuteStatements = []; |
|
43 | + private $_FlushOnExecuteStatements=[]; |
|
44 | 44 | |
45 | 45 | /** |
46 | 46 | * Regular expressions for escaping simple/inline parameter symbols |
47 | 47 | */ |
48 | - const SIMPLE_MARK = '$'; |
|
49 | - const INLINE_SYMBOL = '#'; |
|
50 | - const ESCAPED_SIMPLE_MARK_REGEXP = '/\$\$/'; |
|
51 | - const ESCAPED_INLINE_SYMBOL_REGEXP = '/\#\#/'; |
|
52 | - const SIMPLE_PLACEHOLDER = '`!!`'; |
|
53 | - const INLINE_PLACEHOLDER = '`!!!`'; |
|
48 | + const SIMPLE_MARK='$'; |
|
49 | + const INLINE_SYMBOL='#'; |
|
50 | + const ESCAPED_SIMPLE_MARK_REGEXP='/\$\$/'; |
|
51 | + const ESCAPED_INLINE_SYMBOL_REGEXP='/\#\#/'; |
|
52 | + const SIMPLE_PLACEHOLDER='`!!`'; |
|
53 | + const INLINE_PLACEHOLDER='`!!!`'; |
|
54 | 54 | |
55 | 55 | /** |
56 | 56 | * @param TSqlMapXmlConfiguration parent xml configuration. |
57 | 57 | */ |
58 | 58 | public function __construct(TSqlMapXmlConfiguration $xmlConfig) |
59 | 59 | { |
60 | - $this->_xmlConfig = $xmlConfig; |
|
61 | - $this->_manager = $xmlConfig->getManager(); |
|
60 | + $this->_xmlConfig=$xmlConfig; |
|
61 | + $this->_manager=$xmlConfig->getManager(); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | protected function getConfigFile() |
@@ -72,13 +72,13 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public function configure($filename) |
74 | 74 | { |
75 | - $this->_configFile = $filename; |
|
76 | - $document = $this->loadXmlDocument($filename, $this->_xmlConfig); |
|
77 | - $this->_document = $document; |
|
75 | + $this->_configFile=$filename; |
|
76 | + $document=$this->loadXmlDocument($filename, $this->_xmlConfig); |
|
77 | + $this->_document=$document; |
|
78 | 78 | |
79 | 79 | static $bCacheDependencies; |
80 | - if($bCacheDependencies === null) |
|
81 | - $bCacheDependencies = true; //Prado::getApplication()->getMode() !== TApplicationMode::Performance; |
|
80 | + if($bCacheDependencies===null) |
|
81 | + $bCacheDependencies=true; //Prado::getApplication()->getMode() !== TApplicationMode::Performance; |
|
82 | 82 | |
83 | 83 | if($bCacheDependencies) |
84 | 84 | $this->_manager->getCacheDependencies() |
@@ -121,15 +121,15 @@ discard block |
||
121 | 121 | */ |
122 | 122 | protected function loadResultMap($node) |
123 | 123 | { |
124 | - $resultMap = $this->createResultMap($node); |
|
124 | + $resultMap=$this->createResultMap($node); |
|
125 | 125 | |
126 | 126 | //find extended result map. |
127 | - if(strlen($extendMap = $resultMap->getExtends()) > 0) |
|
127 | + if(strlen($extendMap=$resultMap->getExtends()) > 0) |
|
128 | 128 | { |
129 | 129 | if(!$this->_manager->getResultMaps()->contains($extendMap)) |
130 | 130 | { |
131 | - $extendNode = $this->getElementByIdValue($this->_document, 'resultMap', $extendMap); |
|
132 | - if($extendNode !== null) |
|
131 | + $extendNode=$this->getElementByIdValue($this->_document, 'resultMap', $extendMap); |
|
132 | + if($extendNode!==null) |
|
133 | 133 | $this->loadResultMap($extendNode); |
134 | 134 | } |
135 | 135 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | throw new TSqlMapConfigurationException( |
138 | 138 | 'sqlmap_unable_to_find_parent_result_map', $node, $this->_configFile, $extendMap); |
139 | 139 | |
140 | - $superMap = $this->_manager->getResultMap($extendMap); |
|
140 | + $superMap=$this->_manager->getResultMap($extendMap); |
|
141 | 141 | $resultMap->getColumns()->mergeWith($superMap->getColumns()); |
142 | 142 | } |
143 | 143 | |
@@ -154,37 +154,37 @@ discard block |
||
154 | 154 | */ |
155 | 155 | protected function createResultMap($node) |
156 | 156 | { |
157 | - $resultMap = new TResultMap(); |
|
157 | + $resultMap=new TResultMap(); |
|
158 | 158 | $this->setObjectPropFromNode($resultMap, $node); |
159 | 159 | |
160 | 160 | //result nodes |
161 | 161 | foreach($node->result as $result) |
162 | 162 | { |
163 | - $property = new TResultProperty($resultMap); |
|
163 | + $property=new TResultProperty($resultMap); |
|
164 | 164 | $this->setObjectPropFromNode($property, $result); |
165 | 165 | $resultMap->addResultProperty($property); |
166 | 166 | } |
167 | 167 | |
168 | 168 | //create the discriminator |
169 | - $discriminator = null; |
|
169 | + $discriminator=null; |
|
170 | 170 | if(isset($node->discriminator)) |
171 | 171 | { |
172 | - $discriminator = new TDiscriminator(); |
|
172 | + $discriminator=new TDiscriminator(); |
|
173 | 173 | $this->setObjectPropFromNode($discriminator, $node->discriminator); |
174 | 174 | $discriminator->initMapping($resultMap); |
175 | 175 | } |
176 | 176 | |
177 | 177 | foreach($node->xpath('subMap') as $subMapNode) |
178 | 178 | { |
179 | - if($discriminator === null) |
|
179 | + if($discriminator===null) |
|
180 | 180 | throw new TSqlMapConfigurationException( |
181 | 181 | 'sqlmap_undefined_discriminator', $node, $this->_configFile, $subMapNode); |
182 | - $subMap = new TSubMap; |
|
182 | + $subMap=new TSubMap; |
|
183 | 183 | $this->setObjectPropFromNode($subMap, $subMapNode); |
184 | 184 | $discriminator->addSubMap($subMap); |
185 | 185 | } |
186 | 186 | |
187 | - if($discriminator !== null) |
|
187 | + if($discriminator!==null) |
|
188 | 188 | $resultMap->setDiscriminator($discriminator); |
189 | 189 | |
190 | 190 | return $resultMap; |
@@ -197,22 +197,22 @@ discard block |
||
197 | 197 | */ |
198 | 198 | protected function loadParameterMap($node) |
199 | 199 | { |
200 | - $parameterMap = $this->createParameterMap($node); |
|
200 | + $parameterMap=$this->createParameterMap($node); |
|
201 | 201 | |
202 | - if(strlen($extendMap = $parameterMap->getExtends()) > 0) |
|
202 | + if(strlen($extendMap=$parameterMap->getExtends()) > 0) |
|
203 | 203 | { |
204 | 204 | if(!$this->_manager->getParameterMaps()->contains($extendMap)) |
205 | 205 | { |
206 | - $extendNode = $this->getElementByIdValue($this->_document, 'parameterMap', $extendMap); |
|
207 | - if($extendNode !== null) |
|
206 | + $extendNode=$this->getElementByIdValue($this->_document, 'parameterMap', $extendMap); |
|
207 | + if($extendNode!==null) |
|
208 | 208 | $this->loadParameterMap($extendNode); |
209 | 209 | } |
210 | 210 | |
211 | 211 | if(!$this->_manager->getParameterMaps()->contains($extendMap)) |
212 | 212 | throw new TSqlMapConfigurationException( |
213 | 213 | 'sqlmap_unable_to_find_parent_parameter_map', $node, $this->_configFile, $extendMap); |
214 | - $superMap = $this->_manager->getParameterMap($extendMap); |
|
215 | - $index = 0; |
|
214 | + $superMap=$this->_manager->getParameterMap($extendMap); |
|
215 | + $index=0; |
|
216 | 216 | foreach($superMap->getPropertyNames() as $propertyName) |
217 | 217 | $parameterMap->insertProperty($index++, $superMap->getProperty($propertyName)); |
218 | 218 | } |
@@ -226,11 +226,11 @@ discard block |
||
226 | 226 | */ |
227 | 227 | protected function createParameterMap($node) |
228 | 228 | { |
229 | - $parameterMap = new TParameterMap(); |
|
229 | + $parameterMap=new TParameterMap(); |
|
230 | 230 | $this->setObjectPropFromNode($parameterMap, $node); |
231 | 231 | foreach($node->parameter as $parameter) |
232 | 232 | { |
233 | - $property = new TParameterProperty(); |
|
233 | + $property=new TParameterProperty(); |
|
234 | 234 | $this->setObjectPropFromNode($property, $parameter); |
235 | 235 | $parameterMap->addProperty($property); |
236 | 236 | } |
@@ -243,10 +243,10 @@ discard block |
||
243 | 243 | */ |
244 | 244 | protected function loadStatementTag($node) |
245 | 245 | { |
246 | - $statement = new TSqlMapStatement(); |
|
246 | + $statement=new TSqlMapStatement(); |
|
247 | 247 | $this->setObjectPropFromNode($statement, $node); |
248 | 248 | $this->processSqlStatement($statement, $node); |
249 | - $mappedStatement = new TMappedStatement($this->_manager, $statement); |
|
249 | + $mappedStatement=new TMappedStatement($this->_manager, $statement); |
|
250 | 250 | $this->_manager->addMappedStatement($mappedStatement); |
251 | 251 | } |
252 | 252 | |
@@ -258,12 +258,12 @@ discard block |
||
258 | 258 | */ |
259 | 259 | protected function processSqlStatement($statement, $node) |
260 | 260 | { |
261 | - $commandText = (string)$node; |
|
262 | - if(strlen($extend = $statement->getExtends()) > 0) |
|
261 | + $commandText=(string) $node; |
|
262 | + if(strlen($extend=$statement->getExtends()) > 0) |
|
263 | 263 | { |
264 | - $superNode = $this->getElementByIdValue($this->_document, '*', $extend); |
|
265 | - if($superNode !== null) |
|
266 | - $commandText = (string)$superNode . $commandText; |
|
264 | + $superNode=$this->getElementByIdValue($this->_document, '*', $extend); |
|
265 | + if($superNode!==null) |
|
266 | + $commandText=(string) $superNode.$commandText; |
|
267 | 267 | else |
268 | 268 | throw new TSqlMapConfigurationException( |
269 | 269 | 'sqlmap_unable_to_find_parent_sql', $extend, $this->_configFile, $node); |
@@ -281,27 +281,27 @@ discard block |
||
281 | 281 | */ |
282 | 282 | protected function applyInlineParameterMap($statement, $sqlStatement, $node) |
283 | 283 | { |
284 | - $scope['file'] = $this->_configFile; |
|
285 | - $scope['node'] = $node; |
|
284 | + $scope['file']=$this->_configFile; |
|
285 | + $scope['node']=$node; |
|
286 | 286 | |
287 | - $sqlStatement = preg_replace(self::ESCAPED_INLINE_SYMBOL_REGEXP, self::INLINE_PLACEHOLDER, $sqlStatement); |
|
288 | - if($statement->parameterMap() === null) |
|
287 | + $sqlStatement=preg_replace(self::ESCAPED_INLINE_SYMBOL_REGEXP, self::INLINE_PLACEHOLDER, $sqlStatement); |
|
288 | + if($statement->parameterMap()===null) |
|
289 | 289 | { |
290 | 290 | // Build a Parametermap with the inline parameters. |
291 | 291 | // if they exist. Then delete inline infos from sqltext. |
292 | - $parameterParser = new TInlineParameterMapParser; |
|
293 | - $sqlText = $parameterParser->parse($sqlStatement, $scope); |
|
292 | + $parameterParser=new TInlineParameterMapParser; |
|
293 | + $sqlText=$parameterParser->parse($sqlStatement, $scope); |
|
294 | 294 | if(count($sqlText['parameters']) > 0) |
295 | 295 | { |
296 | - $map = new TParameterMap(); |
|
297 | - $map->setID($statement->getID() . '-InLineParameterMap'); |
|
296 | + $map=new TParameterMap(); |
|
297 | + $map->setID($statement->getID().'-InLineParameterMap'); |
|
298 | 298 | $statement->setInlineParameterMap($map); |
299 | 299 | foreach($sqlText['parameters'] as $property) |
300 | 300 | $map->addProperty($property); |
301 | 301 | } |
302 | - $sqlStatement = $sqlText['sql']; |
|
302 | + $sqlStatement=$sqlText['sql']; |
|
303 | 303 | } |
304 | - $sqlStatement = preg_replace('/' . self::INLINE_PLACEHOLDER . '/', self::INLINE_SYMBOL, $sqlStatement); |
|
304 | + $sqlStatement=preg_replace('/'.self::INLINE_PLACEHOLDER.'/', self::INLINE_SYMBOL, $sqlStatement); |
|
305 | 305 | |
306 | 306 | $this->prepareSql($statement, $sqlStatement, $node); |
307 | 307 | } |
@@ -315,17 +315,17 @@ discard block |
||
315 | 315 | */ |
316 | 316 | protected function prepareSql($statement, $sqlStatement, $node) |
317 | 317 | { |
318 | - $simpleDynamic = new TSimpleDynamicParser; |
|
319 | - $sqlStatement = preg_replace(self::ESCAPED_SIMPLE_MARK_REGEXP, self::SIMPLE_PLACEHOLDER, $sqlStatement); |
|
320 | - $dynamics = $simpleDynamic->parse($sqlStatement); |
|
318 | + $simpleDynamic=new TSimpleDynamicParser; |
|
319 | + $sqlStatement=preg_replace(self::ESCAPED_SIMPLE_MARK_REGEXP, self::SIMPLE_PLACEHOLDER, $sqlStatement); |
|
320 | + $dynamics=$simpleDynamic->parse($sqlStatement); |
|
321 | 321 | if(count($dynamics['parameters']) > 0) |
322 | 322 | { |
323 | - $sql = new TSimpleDynamicSql($dynamics['parameters']); |
|
324 | - $sqlStatement = $dynamics['sql']; |
|
323 | + $sql=new TSimpleDynamicSql($dynamics['parameters']); |
|
324 | + $sqlStatement=$dynamics['sql']; |
|
325 | 325 | } |
326 | 326 | else |
327 | - $sql = new TStaticSql(); |
|
328 | - $sqlStatement = preg_replace('/' . self::SIMPLE_PLACEHOLDER . '/', self::SIMPLE_MARK, $sqlStatement); |
|
327 | + $sql=new TStaticSql(); |
|
328 | + $sqlStatement=preg_replace('/'.self::SIMPLE_PLACEHOLDER.'/', self::SIMPLE_MARK, $sqlStatement); |
|
329 | 329 | $sql->buildPreparedStatement($statement, $sqlStatement); |
330 | 330 | $statement->setSqlText($sql); |
331 | 331 | } |
@@ -336,12 +336,12 @@ discard block |
||
336 | 336 | */ |
337 | 337 | protected function loadSelectTag($node) |
338 | 338 | { |
339 | - $select = new TSqlMapSelect; |
|
339 | + $select=new TSqlMapSelect; |
|
340 | 340 | $this->setObjectPropFromNode($select, $node); |
341 | 341 | $this->processSqlStatement($select, $node); |
342 | - $mappedStatement = new TMappedStatement($this->_manager, $select); |
|
342 | + $mappedStatement=new TMappedStatement($this->_manager, $select); |
|
343 | 343 | if(strlen($select->getCacheModel()) > 0) |
344 | - $mappedStatement = new TCachingStatement($mappedStatement); |
|
344 | + $mappedStatement=new TCachingStatement($mappedStatement); |
|
345 | 345 | |
346 | 346 | $this->_manager->addMappedStatement($mappedStatement); |
347 | 347 | } |
@@ -352,9 +352,9 @@ discard block |
||
352 | 352 | */ |
353 | 353 | protected function loadInsertTag($node) |
354 | 354 | { |
355 | - $insert = $this->createInsertStatement($node); |
|
355 | + $insert=$this->createInsertStatement($node); |
|
356 | 356 | $this->processSqlStatement($insert, $node); |
357 | - $mappedStatement = new TInsertMappedStatement($this->_manager, $insert); |
|
357 | + $mappedStatement=new TInsertMappedStatement($this->_manager, $insert); |
|
358 | 358 | $this->_manager->addMappedStatement($mappedStatement); |
359 | 359 | } |
360 | 360 | |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | */ |
366 | 366 | protected function createInsertStatement($node) |
367 | 367 | { |
368 | - $insert = new TSqlMapInsert; |
|
368 | + $insert=new TSqlMapInsert; |
|
369 | 369 | $this->setObjectPropFromNode($insert, $node); |
370 | 370 | if(isset($node->selectKey)) |
371 | 371 | $this->loadSelectKeyTag($insert, $node->selectKey); |
@@ -378,13 +378,13 @@ discard block |
||
378 | 378 | */ |
379 | 379 | protected function loadSelectKeyTag($insert, $node) |
380 | 380 | { |
381 | - $selectKey = new TSqlMapSelectKey; |
|
381 | + $selectKey=new TSqlMapSelectKey; |
|
382 | 382 | $this->setObjectPropFromNode($selectKey, $node); |
383 | 383 | $selectKey->setID($insert->getID()); |
384 | - $selectKey->setID($insert->getID() . '.SelectKey'); |
|
384 | + $selectKey->setID($insert->getID().'.SelectKey'); |
|
385 | 385 | $this->processSqlStatement($selectKey, $node); |
386 | 386 | $insert->setSelectKey($selectKey); |
387 | - $mappedStatement = new TMappedStatement($this->_manager, $selectKey); |
|
387 | + $mappedStatement=new TMappedStatement($this->_manager, $selectKey); |
|
388 | 388 | $this->_manager->addMappedStatement($mappedStatement); |
389 | 389 | } |
390 | 390 | |
@@ -394,10 +394,10 @@ discard block |
||
394 | 394 | */ |
395 | 395 | protected function loadUpdateTag($node) |
396 | 396 | { |
397 | - $update = new TSqlMapUpdate; |
|
397 | + $update=new TSqlMapUpdate; |
|
398 | 398 | $this->setObjectPropFromNode($update, $node); |
399 | 399 | $this->processSqlStatement($update, $node); |
400 | - $mappedStatement = new TUpdateMappedStatement($this->_manager, $update); |
|
400 | + $mappedStatement=new TUpdateMappedStatement($this->_manager, $update); |
|
401 | 401 | $this->_manager->addMappedStatement($mappedStatement); |
402 | 402 | } |
403 | 403 | |
@@ -407,10 +407,10 @@ discard block |
||
407 | 407 | */ |
408 | 408 | protected function loadDeleteTag($node) |
409 | 409 | { |
410 | - $delete = new TSqlMapDelete; |
|
410 | + $delete=new TSqlMapDelete; |
|
411 | 411 | $this->setObjectPropFromNode($delete, $node); |
412 | 412 | $this->processSqlStatement($delete, $node); |
413 | - $mappedStatement = new TDeleteMappedStatement($this->_manager, $delete); |
|
413 | + $mappedStatement=new TDeleteMappedStatement($this->_manager, $delete); |
|
414 | 414 | $this->_manager->addMappedStatement($mappedStatement); |
415 | 415 | } |
416 | 416 | |
@@ -430,23 +430,23 @@ discard block |
||
430 | 430 | */ |
431 | 431 | protected function loadCacheModel($node) |
432 | 432 | { |
433 | - $cacheModel = new TSqlMapCacheModel; |
|
434 | - $properties = ['id','implementation']; |
|
433 | + $cacheModel=new TSqlMapCacheModel; |
|
434 | + $properties=['id', 'implementation']; |
|
435 | 435 | foreach($node->attributes() as $name => $value) |
436 | 436 | { |
437 | 437 | if(in_array(strtolower($name), $properties)) |
438 | - $cacheModel->{'set' . $name}((string)$value); |
|
438 | + $cacheModel->{'set'.$name}((string) $value); |
|
439 | 439 | } |
440 | - $cache = Prado::createComponent($cacheModel->getImplementationClass(), $cacheModel); |
|
440 | + $cache=Prado::createComponent($cacheModel->getImplementationClass(), $cacheModel); |
|
441 | 441 | $this->setObjectPropFromNode($cache, $node, $properties); |
442 | 442 | |
443 | 443 | foreach($node->xpath('property') as $propertyNode) |
444 | 444 | { |
445 | - $name = $propertyNode->attributes()->name; |
|
446 | - if($name === null || $name === '') continue; |
|
445 | + $name=$propertyNode->attributes()->name; |
|
446 | + if($name===null || $name==='') continue; |
|
447 | 447 | |
448 | - $value = $propertyNode->attributes()->value; |
|
449 | - if($value === null || $value === '') continue; |
|
448 | + $value=$propertyNode->attributes()->value; |
|
449 | + if($value===null || $value==='') continue; |
|
450 | 450 | |
451 | 451 | if(!TPropertyAccess::has($cache, $name)) continue; |
452 | 452 | |
@@ -468,27 +468,27 @@ discard block |
||
468 | 468 | */ |
469 | 469 | protected function loadFlushInterval($cacheModel, $node) |
470 | 470 | { |
471 | - $flushInterval = $node->xpath('flushInterval'); |
|
472 | - if($flushInterval === null || count($flushInterval) === 0) return; |
|
473 | - $duration = 0; |
|
471 | + $flushInterval=$node->xpath('flushInterval'); |
|
472 | + if($flushInterval===null || count($flushInterval)===0) return; |
|
473 | + $duration=0; |
|
474 | 474 | foreach($flushInterval[0]->attributes() as $name => $value) |
475 | 475 | { |
476 | 476 | switch(strToLower($name)) |
477 | 477 | { |
478 | 478 | case 'seconds': |
479 | - $duration += (integer)$value; |
|
479 | + $duration+=(integer) $value; |
|
480 | 480 | break; |
481 | 481 | case 'minutes': |
482 | - $duration += 60 * (integer)$value; |
|
482 | + $duration+=60 * (integer) $value; |
|
483 | 483 | break; |
484 | 484 | case 'hours': |
485 | - $duration += 3600 * (integer)$value; |
|
485 | + $duration+=3600 * (integer) $value; |
|
486 | 486 | break; |
487 | 487 | case 'days': |
488 | - $duration += 86400 * (integer)$value; |
|
488 | + $duration+=86400 * (integer) $value; |
|
489 | 489 | break; |
490 | 490 | case 'duration': |
491 | - $duration = (integer)$value; |
|
491 | + $duration=(integer) $value; |
|
492 | 492 | break 2; // switch, foreach |
493 | 493 | } |
494 | 494 | } |
@@ -503,13 +503,13 @@ discard block |
||
503 | 503 | */ |
504 | 504 | protected function loadFlushOnCache($cacheModel, $parent, $node) |
505 | 505 | { |
506 | - $id = $cacheModel->getID(); |
|
506 | + $id=$cacheModel->getID(); |
|
507 | 507 | if(!isset($this->_FlushOnExecuteStatements[$id])) |
508 | - $this->_FlushOnExecuteStatements[$id] = []; |
|
508 | + $this->_FlushOnExecuteStatements[$id]=[]; |
|
509 | 509 | foreach($node->attributes() as $name => $value) |
510 | 510 | { |
511 | - if(strtolower($name) === 'statement') |
|
512 | - $this->_FlushOnExecuteStatements[$id][] = (string)$value; |
|
511 | + if(strtolower($name)==='statement') |
|
512 | + $this->_FlushOnExecuteStatements[$id][]=(string) $value; |
|
513 | 513 | } |
514 | 514 | } |
515 | 515 | |
@@ -520,10 +520,10 @@ discard block |
||
520 | 520 | { |
521 | 521 | foreach($this->_FlushOnExecuteStatements as $cacheID => $statementIDs) |
522 | 522 | { |
523 | - $cacheModel = $this->_manager->getCacheModel($cacheID); |
|
523 | + $cacheModel=$this->_manager->getCacheModel($cacheID); |
|
524 | 524 | foreach($statementIDs as $statementID) |
525 | 525 | { |
526 | - $statement = $this->_manager->getMappedStatement($statementID); |
|
526 | + $statement=$this->_manager->getMappedStatement($statementID); |
|
527 | 527 | $cacheModel->registerTriggerStatement($statement); |
528 | 528 | } |
529 | 529 | } |
@@ -322,8 +322,7 @@ |
||
322 | 322 | { |
323 | 323 | $sql = new TSimpleDynamicSql($dynamics['parameters']); |
324 | 324 | $sqlStatement = $dynamics['sql']; |
325 | - } |
|
326 | - else |
|
325 | + } else |
|
327 | 326 | $sql = new TStaticSql(); |
328 | 327 | $sqlStatement = preg_replace('/' . self::SIMPLE_PLACEHOLDER . '/', self::SIMPLE_MARK, $sqlStatement); |
329 | 328 | $sql->buildPreparedStatement($statement, $sqlStatement); |