@@ -89,6 +89,7 @@ discard block |
||
| 89 | 89 | * Updates the table with new data. |
| 90 | 90 | * @param array date for update. |
| 91 | 91 | * @param TSqlCriteria update conditions and parameters. |
| 92 | + * @param TSqlCriteria $criteria |
|
| 92 | 93 | * @return integer number of records affected. |
| 93 | 94 | */ |
| 94 | 95 | public function update($data, $criteria) |
@@ -207,6 +208,9 @@ discard block |
||
| 207 | 208 | return $this->onExecuteCommand($command,$command->execute()); |
| 208 | 209 | } |
| 209 | 210 | |
| 211 | + /** |
|
| 212 | + * @param TDbTableInfo $table |
|
| 213 | + */ |
|
| 210 | 214 | public function getIndexKeyCondition($table,$fields,$values) |
| 211 | 215 | { |
| 212 | 216 | if (!count($values)) |
@@ -351,7 +355,7 @@ discard block |
||
| 351 | 355 | * Inserts a new record into the table. Each array key must |
| 352 | 356 | * correspond to a column name in the table unless a null value is permitted. |
| 353 | 357 | * @param array new record data. |
| 354 | - * @return mixed last insert id if one column contains a serial or sequence, |
|
| 358 | + * @return string|boolean last insert id if one column contains a serial or sequence, |
|
| 355 | 359 | * otherwise true if command executes successfully and affected 1 or more rows. |
| 356 | 360 | */ |
| 357 | 361 | public function insert($data) |
@@ -370,7 +374,7 @@ discard block |
||
| 370 | 374 | /** |
| 371 | 375 | * Iterate through all the columns and returns the last insert id of the |
| 372 | 376 | * first column that has a sequence or serial. |
| 373 | - * @return mixed last insert id, null if none is found. |
|
| 377 | + * @return string|null last insert id, null if none is found. |
|
| 374 | 378 | */ |
| 375 | 379 | public function getLastInsertID() |
| 376 | 380 | { |
@@ -381,6 +385,7 @@ discard block |
||
| 381 | 385 | * @param string __call method name |
| 382 | 386 | * @param string criteria conditions |
| 383 | 387 | * @param array method arguments |
| 388 | + * @param string $condition |
|
| 384 | 389 | * @return TActiveRecordCriteria criteria created from the method name and its arguments. |
| 385 | 390 | */ |
| 386 | 391 | public function createCriteriaFromString($method, $condition, $args) |
@@ -434,6 +439,7 @@ discard block |
||
| 434 | 439 | * inspected to obtain the sql query to be executed. |
| 435 | 440 | * @param TDataGatewayCommand originator $sender |
| 436 | 441 | * @param TDataGatewayEventParameter |
| 442 | + * @param TDbCommand $command |
|
| 437 | 443 | */ |
| 438 | 444 | public function onCreateCommand($command, $criteria) |
| 439 | 445 | { |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function __construct($builder) |
| 45 | 45 | { |
| 46 | - $this->_builder = $builder; |
|
| 46 | + $this->_builder=$builder; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -77,10 +77,10 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | public function delete($criteria) |
| 79 | 79 | { |
| 80 | - $where = $criteria->getCondition(); |
|
| 81 | - $parameters = $criteria->getParameters()->toArray(); |
|
| 82 | - $command = $this->getBuilder()->createDeleteCommand($where, $parameters); |
|
| 83 | - $this->onCreateCommand($command,$criteria); |
|
| 80 | + $where=$criteria->getCondition(); |
|
| 81 | + $parameters=$criteria->getParameters()->toArray(); |
|
| 82 | + $command=$this->getBuilder()->createDeleteCommand($where, $parameters); |
|
| 83 | + $this->onCreateCommand($command, $criteria); |
|
| 84 | 84 | $command->prepare(); |
| 85 | 85 | return $command->execute(); |
| 86 | 86 | } |
@@ -93,10 +93,10 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public function update($data, $criteria) |
| 95 | 95 | { |
| 96 | - $where = $criteria->getCondition(); |
|
| 97 | - $parameters = $criteria->getParameters()->toArray(); |
|
| 98 | - $command = $this->getBuilder()->createUpdateCommand($data,$where, $parameters); |
|
| 99 | - $this->onCreateCommand($command,$criteria); |
|
| 96 | + $where=$criteria->getCondition(); |
|
| 97 | + $parameters=$criteria->getParameters()->toArray(); |
|
| 98 | + $command=$this->getBuilder()->createUpdateCommand($data, $where, $parameters); |
|
| 99 | + $this->onCreateCommand($command, $criteria); |
|
| 100 | 100 | $command->prepare(); |
| 101 | 101 | return $this->onExecuteCommand($command, $command->execute()); |
| 102 | 102 | } |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function updateByPk($data, $keys) |
| 110 | 110 | { |
| 111 | - list($where, $parameters) = $this->getPrimaryKeyCondition((array)$keys); |
|
| 111 | + list($where, $parameters)=$this->getPrimaryKeyCondition((array) $keys); |
|
| 112 | 112 | return $this->update($data, new TSqlCriteria($where, $parameters)); |
| 113 | 113 | } |
| 114 | 114 | |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | public function find($criteria) |
| 121 | 121 | { |
| 122 | - $command = $this->getFindCommand($criteria); |
|
| 122 | + $command=$this->getFindCommand($criteria); |
|
| 123 | 123 | return $this->onExecuteCommand($command, $command->queryRow()); |
| 124 | 124 | } |
| 125 | 125 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | public function findAll($criteria) |
| 132 | 132 | { |
| 133 | - $command = $this->getFindCommand($criteria); |
|
| 133 | + $command=$this->getFindCommand($criteria); |
|
| 134 | 134 | return $this->onExecuteCommand($command, $command->query()); |
| 135 | 135 | } |
| 136 | 136 | |
@@ -143,13 +143,13 @@ discard block |
||
| 143 | 143 | { |
| 144 | 144 | if($criteria===null) |
| 145 | 145 | return $this->getBuilder()->createFindCommand(); |
| 146 | - $where = $criteria->getCondition(); |
|
| 147 | - $parameters = $criteria->getParameters()->toArray(); |
|
| 148 | - $ordering = $criteria->getOrdersBy(); |
|
| 149 | - $limit = $criteria->getLimit(); |
|
| 150 | - $offset = $criteria->getOffset(); |
|
| 151 | - $select = $criteria->getSelect(); |
|
| 152 | - $command = $this->getBuilder()->createFindCommand($where,$parameters,$ordering,$limit,$offset,$select); |
|
| 146 | + $where=$criteria->getCondition(); |
|
| 147 | + $parameters=$criteria->getParameters()->toArray(); |
|
| 148 | + $ordering=$criteria->getOrdersBy(); |
|
| 149 | + $limit=$criteria->getLimit(); |
|
| 150 | + $offset=$criteria->getOffset(); |
|
| 151 | + $select=$criteria->getSelect(); |
|
| 152 | + $command=$this->getBuilder()->createFindCommand($where, $parameters, $ordering, $limit, $offset, $select); |
|
| 153 | 153 | $this->onCreateCommand($command, $criteria); |
| 154 | 154 | return $command; |
| 155 | 155 | } |
@@ -162,9 +162,9 @@ discard block |
||
| 162 | 162 | { |
| 163 | 163 | if($keys===null) |
| 164 | 164 | return null; |
| 165 | - list($where, $parameters) = $this->getPrimaryKeyCondition((array)$keys); |
|
| 166 | - $command = $this->getBuilder()->createFindCommand($where, $parameters); |
|
| 167 | - $this->onCreateCommand($command, new TSqlCriteria($where,$parameters)); |
|
| 165 | + list($where, $parameters)=$this->getPrimaryKeyCondition((array) $keys); |
|
| 166 | + $command=$this->getBuilder()->createFindCommand($where, $parameters); |
|
| 167 | + $this->onCreateCommand($command, new TSqlCriteria($where, $parameters)); |
|
| 168 | 168 | return $this->onExecuteCommand($command, $command->queryRow()); |
| 169 | 169 | } |
| 170 | 170 | |
@@ -174,22 +174,22 @@ discard block |
||
| 174 | 174 | */ |
| 175 | 175 | public function findAllByPk($keys) |
| 176 | 176 | { |
| 177 | - $where = $this->getCompositeKeyCondition((array)$keys); |
|
| 178 | - $command = $this->getBuilder()->createFindCommand($where); |
|
| 179 | - $this->onCreateCommand($command, new TSqlCriteria($where,$keys)); |
|
| 180 | - return $this->onExecuteCommand($command,$command->query()); |
|
| 177 | + $where=$this->getCompositeKeyCondition((array) $keys); |
|
| 178 | + $command=$this->getBuilder()->createFindCommand($where); |
|
| 179 | + $this->onCreateCommand($command, new TSqlCriteria($where, $keys)); |
|
| 180 | + return $this->onExecuteCommand($command, $command->query()); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - public function findAllByIndex($criteria,$fields,$values) |
|
| 183 | + public function findAllByIndex($criteria, $fields, $values) |
|
| 184 | 184 | { |
| 185 | - $index = $this->getIndexKeyCondition($this->getTableInfo(),$fields,$values); |
|
| 186 | - if(strlen($where = $criteria->getCondition())>0) |
|
| 185 | + $index=$this->getIndexKeyCondition($this->getTableInfo(), $fields, $values); |
|
| 186 | + if(strlen($where=$criteria->getCondition()) > 0) |
|
| 187 | 187 | $criteria->setCondition("({$index}) AND ({$where})"); |
| 188 | 188 | else |
| 189 | 189 | $criteria->setCondition($index); |
| 190 | - $command = $this->getFindCommand($criteria); |
|
| 190 | + $command=$this->getFindCommand($criteria); |
|
| 191 | 191 | $this->onCreateCommand($command, $criteria); |
| 192 | - return $this->onExecuteCommand($command,$command->query()); |
|
| 192 | + return $this->onExecuteCommand($command, $command->query()); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
@@ -200,22 +200,22 @@ discard block |
||
| 200 | 200 | { |
| 201 | 201 | if(count($keys)==0) |
| 202 | 202 | return 0; |
| 203 | - $where = $this->getCompositeKeyCondition((array)$keys); |
|
| 204 | - $command = $this->getBuilder()->createDeleteCommand($where); |
|
| 205 | - $this->onCreateCommand($command, new TSqlCriteria($where,$keys)); |
|
| 203 | + $where=$this->getCompositeKeyCondition((array) $keys); |
|
| 204 | + $command=$this->getBuilder()->createDeleteCommand($where); |
|
| 205 | + $this->onCreateCommand($command, new TSqlCriteria($where, $keys)); |
|
| 206 | 206 | $command->prepare(); |
| 207 | - return $this->onExecuteCommand($command,$command->execute()); |
|
| 207 | + return $this->onExecuteCommand($command, $command->execute()); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - public function getIndexKeyCondition($table,$fields,$values) |
|
| 210 | + public function getIndexKeyCondition($table, $fields, $values) |
|
| 211 | 211 | { |
| 212 | - if (!count($values)) |
|
| 212 | + if(!count($values)) |
|
| 213 | 213 | return 'FALSE'; |
| 214 | - $columns = array(); |
|
| 215 | - $tableName = $table->getTableFullName(); |
|
| 214 | + $columns=array(); |
|
| 215 | + $tableName=$table->getTableFullName(); |
|
| 216 | 216 | foreach($fields as $field) |
| 217 | - $columns[] = $tableName.'.'.$table->getColumn($field)->getColumnName(); |
|
| 218 | - return '('.implode(', ',$columns).') IN '.$this->quoteTuple($values); |
|
| 217 | + $columns[]=$tableName.'.'.$table->getColumn($field)->getColumnName(); |
|
| 218 | + return '('.implode(', ', $columns).') IN '.$this->quoteTuple($values); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | /** |
@@ -225,26 +225,26 @@ discard block |
||
| 225 | 225 | */ |
| 226 | 226 | protected function getCompositeKeyCondition($values) |
| 227 | 227 | { |
| 228 | - $primary = $this->getTableInfo()->getPrimaryKeys(); |
|
| 229 | - $count = count($primary); |
|
| 228 | + $primary=$this->getTableInfo()->getPrimaryKeys(); |
|
| 229 | + $count=count($primary); |
|
| 230 | 230 | if($count===0) |
| 231 | 231 | { |
| 232 | 232 | throw new TDbException('dbtablegateway_no_primary_key_found', |
| 233 | 233 | $this->getTableInfo()->getTableFullName()); |
| 234 | 234 | } |
| 235 | - if(!is_array($values) || count($values) === 0) |
|
| 235 | + if(!is_array($values) || count($values)===0) |
|
| 236 | 236 | { |
| 237 | 237 | throw new TDbException('dbtablegateway_missing_pk_values', |
| 238 | 238 | $this->getTableInfo()->getTableFullName()); |
| 239 | 239 | } |
| 240 | - if($count>1 && (!isset($values[0]) || !is_array($values[0]))) |
|
| 241 | - $values = array($values); |
|
| 242 | - if($count > 1 && count($values[0]) !== $count) |
|
| 240 | + if($count > 1 && (!isset($values[0]) || !is_array($values[0]))) |
|
| 241 | + $values=array($values); |
|
| 242 | + if($count > 1 && count($values[0])!==$count) |
|
| 243 | 243 | { |
| 244 | 244 | throw new TDbException('dbtablegateway_pk_value_count_mismatch', |
| 245 | 245 | $this->getTableInfo()->getTableFullName()); |
| 246 | 246 | } |
| 247 | - return $this->getIndexKeyCondition($this->getTableInfo(),$primary, $values); |
|
| 247 | + return $this->getIndexKeyCondition($this->getTableInfo(), $primary, $values); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | /** |
@@ -254,10 +254,10 @@ discard block |
||
| 254 | 254 | */ |
| 255 | 255 | protected function quoteTuple($array) |
| 256 | 256 | { |
| 257 | - $conn = $this->getDbConnection(); |
|
| 258 | - $data = array(); |
|
| 257 | + $conn=$this->getDbConnection(); |
|
| 258 | + $data=array(); |
|
| 259 | 259 | foreach($array as $k=>$v) |
| 260 | - $data[] = is_array($v) ? $this->quoteTuple($v) : $conn->quoteString($v); |
|
| 260 | + $data[]=is_array($v) ? $this->quoteTuple($v) : $conn->quoteString($v); |
|
| 261 | 261 | return '('.implode(', ', $data).')'; |
| 262 | 262 | } |
| 263 | 263 | |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | */ |
| 269 | 269 | protected function getPrimaryKeyCondition($values) |
| 270 | 270 | { |
| 271 | - $primary = $this->getTableInfo()->getPrimaryKeys(); |
|
| 271 | + $primary=$this->getTableInfo()->getPrimaryKeys(); |
|
| 272 | 272 | if(count($primary)===0) |
| 273 | 273 | { |
| 274 | 274 | throw new TDbException('dbtablegateway_no_primary_key_found', |
@@ -276,12 +276,12 @@ discard block |
||
| 276 | 276 | } |
| 277 | 277 | $criteria=array(); |
| 278 | 278 | $bindings=array(); |
| 279 | - $i = 0; |
|
| 279 | + $i=0; |
|
| 280 | 280 | foreach($primary as $key) |
| 281 | 281 | { |
| 282 | - $column = $this->getTableInfo()->getColumn($key)->getColumnName(); |
|
| 283 | - $criteria[] = $column.' = :'.$key; |
|
| 284 | - $bindings[$key] = isset($values[$key])?$values[$key]:$values[$i++]; |
|
| 282 | + $column=$this->getTableInfo()->getColumn($key)->getColumnName(); |
|
| 283 | + $criteria[]=$column.' = :'.$key; |
|
| 284 | + $bindings[$key]=isset($values[$key]) ? $values[$key] : $values[$i++]; |
|
| 285 | 285 | } |
| 286 | 286 | return array(implode(' AND ', $criteria), $bindings); |
| 287 | 287 | } |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | */ |
| 294 | 294 | public function findBySql($criteria) |
| 295 | 295 | { |
| 296 | - $command = $this->getSqlCommand($criteria); |
|
| 296 | + $command=$this->getSqlCommand($criteria); |
|
| 297 | 297 | return $this->onExecuteCommand($command, $command->queryRow()); |
| 298 | 298 | } |
| 299 | 299 | |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | */ |
| 305 | 305 | public function findAllBySql($criteria) |
| 306 | 306 | { |
| 307 | - $command = $this->getSqlCommand($criteria); |
|
| 307 | + $command=$this->getSqlCommand($criteria); |
|
| 308 | 308 | return $this->onExecuteCommand($command, $command->query()); |
| 309 | 309 | } |
| 310 | 310 | |
@@ -315,15 +315,15 @@ discard block |
||
| 315 | 315 | */ |
| 316 | 316 | protected function getSqlCommand($criteria) |
| 317 | 317 | { |
| 318 | - $sql = $criteria->getCondition(); |
|
| 319 | - $ordering = $criteria->getOrdersBy(); |
|
| 320 | - $limit = $criteria->getLimit(); |
|
| 321 | - $offset = $criteria->getOffset(); |
|
| 318 | + $sql=$criteria->getCondition(); |
|
| 319 | + $ordering=$criteria->getOrdersBy(); |
|
| 320 | + $limit=$criteria->getLimit(); |
|
| 321 | + $offset=$criteria->getOffset(); |
|
| 322 | 322 | if(count($ordering) > 0) |
| 323 | - $sql = $this->getBuilder()->applyOrdering($sql, $ordering); |
|
| 324 | - if($limit>=0 || $offset>=0) |
|
| 325 | - $sql = $this->getBuilder()->applyLimitOffset($sql, $limit, $offset); |
|
| 326 | - $command = $this->getBuilder()->createCommand($sql); |
|
| 323 | + $sql=$this->getBuilder()->applyOrdering($sql, $ordering); |
|
| 324 | + if($limit >= 0 || $offset >= 0) |
|
| 325 | + $sql=$this->getBuilder()->applyLimitOffset($sql, $limit, $offset); |
|
| 326 | + $command=$this->getBuilder()->createCommand($sql); |
|
| 327 | 327 | $this->getBuilder()->bindArrayValues($command, $criteria->getParameters()->toArray()); |
| 328 | 328 | $this->onCreateCommand($command, $criteria); |
| 329 | 329 | return $command; |
@@ -336,15 +336,15 @@ discard block |
||
| 336 | 336 | public function count($criteria) |
| 337 | 337 | { |
| 338 | 338 | if($criteria===null) |
| 339 | - return (int)$this->getBuilder()->createCountCommand()->queryScalar(); |
|
| 340 | - $where = $criteria->getCondition(); |
|
| 341 | - $parameters = $criteria->getParameters()->toArray(); |
|
| 342 | - $ordering = $criteria->getOrdersBy(); |
|
| 343 | - $limit = $criteria->getLimit(); |
|
| 344 | - $offset = $criteria->getOffset(); |
|
| 345 | - $command = $this->getBuilder()->createCountCommand($where,$parameters,$ordering,$limit,$offset); |
|
| 339 | + return (int) $this->getBuilder()->createCountCommand()->queryScalar(); |
|
| 340 | + $where=$criteria->getCondition(); |
|
| 341 | + $parameters=$criteria->getParameters()->toArray(); |
|
| 342 | + $ordering=$criteria->getOrdersBy(); |
|
| 343 | + $limit=$criteria->getLimit(); |
|
| 344 | + $offset=$criteria->getOffset(); |
|
| 345 | + $command=$this->getBuilder()->createCountCommand($where, $parameters, $ordering, $limit, $offset); |
|
| 346 | 346 | $this->onCreateCommand($command, $criteria); |
| 347 | - return $this->onExecuteCommand($command, (int)$command->queryScalar()); |
|
| 347 | + return $this->onExecuteCommand($command, (int) $command->queryScalar()); |
|
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | /** |
@@ -357,12 +357,12 @@ discard block |
||
| 357 | 357 | public function insert($data) |
| 358 | 358 | { |
| 359 | 359 | $command=$this->getBuilder()->createInsertCommand($data); |
| 360 | - $this->onCreateCommand($command, new TSqlCriteria(null,$data)); |
|
| 360 | + $this->onCreateCommand($command, new TSqlCriteria(null, $data)); |
|
| 361 | 361 | $command->prepare(); |
| 362 | 362 | if($this->onExecuteCommand($command, $command->execute()) > 0) |
| 363 | 363 | { |
| 364 | - $value = $this->getLastInsertId(); |
|
| 365 | - return $value !== null ? $value : true; |
|
| 364 | + $value=$this->getLastInsertId(); |
|
| 365 | + return $value!==null ? $value : true; |
|
| 366 | 366 | } |
| 367 | 367 | return false; |
| 368 | 368 | } |
@@ -385,14 +385,14 @@ discard block |
||
| 385 | 385 | */ |
| 386 | 386 | public function createCriteriaFromString($method, $condition, $args) |
| 387 | 387 | { |
| 388 | - $fields = $this->extractMatchingConditions($method, $condition); |
|
| 389 | - $args=count($args) === 1 && is_array($args[0]) ? $args[0] : $args; |
|
| 390 | - if(count($fields)>count($args)) |
|
| 388 | + $fields=$this->extractMatchingConditions($method, $condition); |
|
| 389 | + $args=count($args)===1 && is_array($args[0]) ? $args[0] : $args; |
|
| 390 | + if(count($fields) > count($args)) |
|
| 391 | 391 | { |
| 392 | 392 | throw new TDbException('dbtablegateway_mismatch_args_exception', |
| 393 | - $method,count($fields),count($args)); |
|
| 393 | + $method, count($fields), count($args)); |
|
| 394 | 394 | } |
| 395 | - return new TSqlCriteria(implode(' ',$fields), $args); |
|
| 395 | + return new TSqlCriteria(implode(' ', $fields), $args); |
|
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | /** |
@@ -404,25 +404,25 @@ discard block |
||
| 404 | 404 | */ |
| 405 | 405 | protected function extractMatchingConditions($method, $condition) |
| 406 | 406 | { |
| 407 | - $table = $this->getTableInfo(); |
|
| 408 | - $columns = $table->getLowerCaseColumnNames(); |
|
| 409 | - $regexp = '/('.implode('|', array_keys($columns)).')(and|_and_|or|_or_)?/i'; |
|
| 410 | - $matches = array(); |
|
| 411 | - if(!preg_match_all($regexp, strtolower($condition), $matches,PREG_SET_ORDER)) |
|
| 407 | + $table=$this->getTableInfo(); |
|
| 408 | + $columns=$table->getLowerCaseColumnNames(); |
|
| 409 | + $regexp='/('.implode('|', array_keys($columns)).')(and|_and_|or|_or_)?/i'; |
|
| 410 | + $matches=array(); |
|
| 411 | + if(!preg_match_all($regexp, strtolower($condition), $matches, PREG_SET_ORDER)) |
|
| 412 | 412 | { |
| 413 | 413 | throw new TDbException('dbtablegateway_mismatch_column_name', |
| 414 | 414 | $method, implode(', ', $columns), $table->getTableFullName()); |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | - $fields = array(); |
|
| 417 | + $fields=array(); |
|
| 418 | 418 | foreach($matches as $match) |
| 419 | 419 | { |
| 420 | - $key = $columns[$match[1]]; |
|
| 421 | - $column = $table->getColumn($key)->getColumnName(); |
|
| 422 | - $sql = $column . ' = ? '; |
|
| 420 | + $key=$columns[$match[1]]; |
|
| 421 | + $column=$table->getColumn($key)->getColumnName(); |
|
| 422 | + $sql=$column.' = ? '; |
|
| 423 | 423 | if(count($match) > 2) |
| 424 | - $sql .= strtoupper(str_replace('_', '', $match[2])); |
|
| 425 | - $fields[] = $sql; |
|
| 424 | + $sql.=strtoupper(str_replace('_', '', $match[2])); |
|
| 425 | + $fields[]=$sql; |
|
| 426 | 426 | } |
| 427 | 427 | return $fields; |
| 428 | 428 | } |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | */ |
| 438 | 438 | public function onCreateCommand($command, $criteria) |
| 439 | 439 | { |
| 440 | - $this->raiseEvent('OnCreateCommand', $this, new TDataGatewayEventParameter($command,$criteria)); |
|
| 440 | + $this->raiseEvent('OnCreateCommand', $this, new TDataGatewayEventParameter($command, $criteria)); |
|
| 441 | 441 | } |
| 442 | 442 | |
| 443 | 443 | /** |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | */ |
| 452 | 452 | public function onExecuteCommand($command, $result) |
| 453 | 453 | { |
| 454 | - $parameter = new TDataGatewayResultEventParameter($command, $result); |
|
| 454 | + $parameter=new TDataGatewayResultEventParameter($command, $result); |
|
| 455 | 455 | $this->raiseEvent('OnExecuteCommand', $this, $parameter); |
| 456 | 456 | return $parameter->getResult(); |
| 457 | 457 | } |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | private $_command; |
| 472 | 472 | private $_criteria; |
| 473 | 473 | |
| 474 | - public function __construct($command,$criteria) |
|
| 474 | + public function __construct($command, $criteria) |
|
| 475 | 475 | { |
| 476 | 476 | $this->_command=$command; |
| 477 | 477 | $this->_criteria=$criteria; |
@@ -511,7 +511,7 @@ discard block |
||
| 511 | 511 | private $_command; |
| 512 | 512 | private $_result; |
| 513 | 513 | |
| 514 | - public function __construct($command,$result) |
|
| 514 | + public function __construct($command, $result) |
|
| 515 | 515 | { |
| 516 | 516 | $this->_command=$command; |
| 517 | 517 | $this->_result=$result; |
@@ -1,14 +1,14 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * TDataGatewayCommand, TDataGatewayEventParameter and TDataGatewayResultEventParameter class file. |
|
| 4 | - * |
|
| 5 | - * @author Wei Zhuo <weizhuo[at]gmail[dot]com> |
|
| 6 | - * @link https://github.com/pradosoft/prado |
|
| 7 | - * @copyright Copyright © 2005-2016 The PRADO Group |
|
| 8 | - * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
| 9 | - * @version $Id$ |
|
| 10 | - * @package System.Data.DataGateway |
|
| 11 | - */ |
|
| 3 | + * TDataGatewayCommand, TDataGatewayEventParameter and TDataGatewayResultEventParameter class file. |
|
| 4 | + * |
|
| 5 | + * @author Wei Zhuo <weizhuo[at]gmail[dot]com> |
|
| 6 | + * @link https://github.com/pradosoft/prado |
|
| 7 | + * @copyright Copyright © 2005-2016 The PRADO Group |
|
| 8 | + * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
| 9 | + * @version $Id$ |
|
| 10 | + * @package System.Data.DataGateway |
|
| 11 | + */ |
|
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * TDataGatewayCommand is command builder and executor class for |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | /** |
| 191 | - * @return boolean true if the parameter index are string base, false otherwise. |
|
| 191 | + * @return boolean|null true if the parameter index are string base, false otherwise. |
|
| 192 | 192 | */ |
| 193 | 193 | public function getIsNamedParameters() |
| 194 | 194 | { |
@@ -206,6 +206,7 @@ discard block |
||
| 206 | 206 | |
| 207 | 207 | /** |
| 208 | 208 | * @param mixed ordering clause. |
| 209 | + * @param string $value |
|
| 209 | 210 | */ |
| 210 | 211 | public function setOrdersBy($value) |
| 211 | 212 | { |
@@ -250,6 +251,7 @@ discard block |
||
| 250 | 251 | |
| 251 | 252 | /** |
| 252 | 253 | * @param int record offset. |
| 254 | + * @param double $value |
|
| 253 | 255 | */ |
| 254 | 256 | public function setOffset($value) |
| 255 | 257 | { |
@@ -48,10 +48,10 @@ discard block |
||
| 48 | 48 | public function __construct($condition=null, $parameters=array()) |
| 49 | 49 | { |
| 50 | 50 | if(!is_array($parameters) && func_num_args() > 1) |
| 51 | - $parameters = array_slice(func_get_args(),1); |
|
| 51 | + $parameters=array_slice(func_get_args(), 1); |
|
| 52 | 52 | $this->_parameters=new TAttributeCollection; |
| 53 | 53 | $this->_parameters->setCaseSensitive(true); |
| 54 | - $this->_parameters->copyFrom((array)$parameters); |
|
| 54 | + $this->_parameters->copyFrom((array) $parameters); |
|
| 55 | 55 | $this->_ordersBy=new TAttributeCollection; |
| 56 | 56 | $this->_ordersBy->setCaseSensitive(true); |
| 57 | 57 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | public function setSelect($value) |
| 111 | 111 | { |
| 112 | - $this->_select = $value; |
|
| 112 | + $this->_select=$value; |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | { |
| 129 | 129 | if(empty($value)) { |
| 130 | 130 | // reset the condition |
| 131 | - $this->_condition = null; |
|
| 131 | + $this->_condition=null; |
|
| 132 | 132 | return; |
| 133 | 133 | } |
| 134 | 134 | |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | |
| 141 | 141 | if(preg_match('/ORDER\s+BY\s+(.*?)(?=LIMIT)|ORDER\s+BY\s+(.*?)$/i', $value, $matches) > 0) { |
| 142 | 142 | // condition contains ORDER BY |
| 143 | - $value = str_replace($matches[0], '', $value); |
|
| 143 | + $value=str_replace($matches[0], '', $value); |
|
| 144 | 144 | if(strlen($matches[1]) > 0) { |
| 145 | 145 | $this->setOrdersBy($matches[1]); |
| 146 | 146 | } else if(strlen($matches[2]) > 0) { |
@@ -150,23 +150,23 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | if(preg_match('/LIMIT\s+([\d\s,]+)/i', $value, $matches) > 0) { |
| 152 | 152 | // condition contains limit |
| 153 | - $value = str_replace($matches[0], '', $value); // remove limit from query |
|
| 153 | + $value=str_replace($matches[0], '', $value); // remove limit from query |
|
| 154 | 154 | if(strpos($matches[1], ',')) { // both offset and limit given |
| 155 | - list($offset, $limit) = explode(',', $matches[1]); |
|
| 156 | - $this->_limit = (int)$limit; |
|
| 157 | - $this->_offset = (int)$offset; |
|
| 155 | + list($offset, $limit)=explode(',', $matches[1]); |
|
| 156 | + $this->_limit=(int) $limit; |
|
| 157 | + $this->_offset=(int) $offset; |
|
| 158 | 158 | } else { // only limit given |
| 159 | - $this->_limit = (int)$matches[1]; |
|
| 159 | + $this->_limit=(int) $matches[1]; |
|
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | if(preg_match('/OFFSET\s+(\d+)/i', $value, $matches) > 0) { |
| 164 | 164 | // condition contains offset |
| 165 | - $value = str_replace($matches[0], '', $value); // remove offset from query |
|
| 166 | - $this->_offset = (int)$matches[1]; // set offset in criteria |
|
| 165 | + $value=str_replace($matches[0], '', $value); // remove offset from query |
|
| 166 | + $this->_offset=(int) $matches[1]; // set offset in criteria |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - $this->_condition = trim($value); |
|
| 169 | + $this->_condition=trim($value); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
@@ -213,12 +213,12 @@ discard block |
||
| 213 | 213 | $this->_ordersBy->copyFrom($value); |
| 214 | 214 | else |
| 215 | 215 | { |
| 216 | - $value=trim(preg_replace('/\s+/',' ',(string)$value)); |
|
| 216 | + $value=trim(preg_replace('/\s+/', ' ', (string) $value)); |
|
| 217 | 217 | $orderBys=array(); |
| 218 | - foreach(explode(',',$value) as $orderBy) |
|
| 218 | + foreach(explode(',', $value) as $orderBy) |
|
| 219 | 219 | { |
| 220 | - $vs=explode(' ',trim($orderBy)); |
|
| 221 | - $orderBys[$vs[0]]=isset($vs[1])?$vs[1]:'asc'; |
|
| 220 | + $vs=explode(' ', trim($orderBy)); |
|
| 221 | + $orderBys[$vs[0]]=isset($vs[1]) ? $vs[1] : 'asc'; |
|
| 222 | 222 | } |
| 223 | 223 | $this->_ordersBy->copyFrom($orderBys); |
| 224 | 224 | } |
@@ -261,23 +261,23 @@ discard block |
||
| 261 | 261 | */ |
| 262 | 262 | public function __toString() |
| 263 | 263 | { |
| 264 | - $str = ''; |
|
| 265 | - if(strlen((string)$this->getCondition()) > 0) |
|
| 266 | - $str .= '"'.(string)$this->getCondition().'"'; |
|
| 267 | - $params = array(); |
|
| 264 | + $str=''; |
|
| 265 | + if(strlen((string) $this->getCondition()) > 0) |
|
| 266 | + $str.='"'.(string) $this->getCondition().'"'; |
|
| 267 | + $params=array(); |
|
| 268 | 268 | foreach($this->getParameters() as $k=>$v) |
| 269 | - $params[] = "{$k} => ${v}"; |
|
| 269 | + $params[]="{$k} => ${v}"; |
|
| 270 | 270 | if(count($params) > 0) |
| 271 | - $str .= ', "'.implode(', ',$params).'"'; |
|
| 272 | - $orders = array(); |
|
| 271 | + $str.=', "'.implode(', ', $params).'"'; |
|
| 272 | + $orders=array(); |
|
| 273 | 273 | foreach($this->getOrdersBy() as $k=>$v) |
| 274 | - $orders[] = "{$k} => ${v}"; |
|
| 274 | + $orders[]="{$k} => ${v}"; |
|
| 275 | 275 | if(count($orders) > 0) |
| 276 | - $str .= ', "'.implode(', ',$orders).'"'; |
|
| 277 | - if($this->_limit !==null) |
|
| 278 | - $str .= ', '.$this->_limit; |
|
| 279 | - if($this->_offset !== null) |
|
| 280 | - $str .= ', '.$this->_offset; |
|
| 276 | + $str.=', "'.implode(', ', $orders).'"'; |
|
| 277 | + if($this->_limit!==null) |
|
| 278 | + $str.=', '.$this->_limit; |
|
| 279 | + if($this->_offset!==null) |
|
| 280 | + $str.=', '.$this->_offset; |
|
| 281 | 281 | return $str; |
| 282 | 282 | } |
| 283 | 283 | } |
@@ -132,6 +132,7 @@ discard block |
||
| 132 | 132 | |
| 133 | 133 | /** |
| 134 | 134 | * @param TSubMap add new sub mapping. |
| 135 | + * @param TSubMap $subMap |
|
| 135 | 136 | */ |
| 136 | 137 | public function addSubMap($subMap) |
| 137 | 138 | { |
@@ -140,6 +141,7 @@ discard block |
||
| 140 | 141 | |
| 141 | 142 | /** |
| 142 | 143 | * @param string database value |
| 144 | + * @param string $value |
|
| 143 | 145 | * @return TResultMap result mapping. |
| 144 | 146 | */ |
| 145 | 147 | public function getSubMap($value) |
@@ -151,6 +153,7 @@ discard block |
||
| 151 | 153 | /** |
| 152 | 154 | * Copies the discriminator properties to a new TResultProperty. |
| 153 | 155 | * @param TResultMap result map holding the discriminator. |
| 156 | + * @param TResultMap $resultMap |
|
| 154 | 157 | */ |
| 155 | 158 | public function initMapping($resultMap) |
| 156 | 159 | { |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function setColumn($value) |
| 51 | 51 | { |
| 52 | - $this->_column = $value; |
|
| 52 | + $this->_column=$value; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | public function setType($value) |
| 71 | 71 | { |
| 72 | - $this->_type = $value; |
|
| 72 | + $this->_type=$value; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | public function setTypeHandler($value) |
| 87 | 87 | { |
| 88 | - $this->_typeHandler = $value; |
|
| 88 | + $this->_typeHandler=$value; |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | public function setColumnIndex($value) |
| 105 | 105 | { |
| 106 | - $this->_columnIndex = TPropertyValue::ensureInteger($value); |
|
| 106 | + $this->_columnIndex=TPropertyValue::ensureInteger($value); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | public function setNullValue($value) |
| 121 | 121 | { |
| 122 | - $this->_nullValue = $value; |
|
| 122 | + $this->_nullValue=$value; |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | /** |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | public function addSubMap($subMap) |
| 137 | 137 | { |
| 138 | - $this->_subMaps[] = $subMap; |
|
| 138 | + $this->_subMaps[]=$subMap; |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | public function initMapping($resultMap) |
| 156 | 156 | { |
| 157 | - $this->_mapping = new TResultProperty($resultMap); |
|
| 157 | + $this->_mapping=new TResultProperty($resultMap); |
|
| 158 | 158 | $this->_mapping->setColumn($this->getColumn()); |
| 159 | 159 | $this->_mapping->setColumnIndex($this->getColumnIndex()); |
| 160 | 160 | $this->_mapping->setType($this->getType()); |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | { |
| 171 | 171 | foreach($this->_subMaps as $subMap) |
| 172 | 172 | { |
| 173 | - $this->_resultMaps[$subMap->getValue()] = |
|
| 173 | + $this->_resultMaps[$subMap->getValue()]= |
|
| 174 | 174 | $manager->getResultMap($subMap->getResultMapping()); |
| 175 | 175 | } |
| 176 | 176 | } |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | */ |
| 207 | 207 | public function setValue($value) |
| 208 | 208 | { |
| 209 | - $this->_value = $value; |
|
| 209 | + $this->_value=$value; |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | */ |
| 224 | 224 | public function setResultMapping($value) |
| 225 | 225 | { |
| 226 | - $this->_resultMapping = $value; |
|
| 226 | + $this->_resultMapping=$value; |
|
| 227 | 227 | } |
| 228 | 228 | } |
| 229 | 229 | |
@@ -55,6 +55,7 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * @param string a unique identifier for the <parameterMap>. |
| 58 | + * @param string $value |
|
| 58 | 59 | */ |
| 59 | 60 | public function setID($value) |
| 60 | 61 | { |
@@ -62,7 +63,7 @@ discard block |
||
| 62 | 63 | } |
| 63 | 64 | |
| 64 | 65 | /** |
| 65 | - * @return TParameterProperty[] list of properties for the parameter map. |
|
| 66 | + * @return TList list of properties for the parameter map. |
|
| 66 | 67 | */ |
| 67 | 68 | public function getProperties() |
| 68 | 69 | { |
@@ -112,6 +113,7 @@ discard block |
||
| 112 | 113 | /** |
| 113 | 114 | * @param int parameter property index |
| 114 | 115 | * @param TParameterProperty new parameter property. |
| 116 | + * @param integer $index |
|
| 115 | 117 | */ |
| 116 | 118 | public function insertProperty($index, TParameterProperty $property) |
| 117 | 119 | { |
@@ -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 | } |
@@ -103,6 +103,7 @@ discard block |
||
| 103 | 103 | /** |
| 104 | 104 | * @param string name of the column in the result set from which the value |
| 105 | 105 | * will be used to populate the property. |
| 106 | + * @param string $value |
|
| 106 | 107 | */ |
| 107 | 108 | public function setColumn($value) |
| 108 | 109 | { |
@@ -121,6 +122,7 @@ discard block |
||
| 121 | 122 | /** |
| 122 | 123 | * @param int index of the column in the ResultSet from which the value will |
| 123 | 124 | * be used to populate the object property |
| 125 | + * @param integer $value |
|
| 124 | 126 | */ |
| 125 | 127 | public function setColumnIndex($value) |
| 126 | 128 | { |
@@ -185,6 +187,7 @@ discard block |
||
| 185 | 187 | |
| 186 | 188 | /** |
| 187 | 189 | * @param string custom type handler class name (may use namespace). |
| 190 | + * @param string $value |
|
| 188 | 191 | */ |
| 189 | 192 | public function setTypeHandler($value) |
| 190 | 193 | { |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | private $_hostResultMapID='inplicit internal mapping'; |
| 48 | 48 | |
| 49 | - const LIST_TYPE = 0; |
|
| 50 | - const ARRAY_TYPE = 1; |
|
| 49 | + const LIST_TYPE=0; |
|
| 50 | + const ARRAY_TYPE=1; |
|
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * Gets the containing result map ID. |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | public function __construct($resultMap=null) |
| 57 | 57 | { |
| 58 | 58 | if($resultMap instanceof TResultMap) |
| 59 | - $this->_hostResultMapID = $resultMap->getID(); |
|
| 59 | + $this->_hostResultMapID=$resultMap->getID(); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | public function setNullValue($value) |
| 74 | 74 | { |
| 75 | - $this->_nullValue = $value; |
|
| 75 | + $this->_nullValue=$value; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function setProperty($value) |
| 90 | 90 | { |
| 91 | - $this->_propertyName = $value; |
|
| 91 | + $this->_propertyName=$value; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | public function setColumn($value) |
| 108 | 108 | { |
| 109 | - $this->_columnName = $value; |
|
| 109 | + $this->_columnName=$value; |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | public function setColumnIndex($value) |
| 126 | 126 | { |
| 127 | - $this->_columnIndex = TPropertyValue::ensureInteger($value); |
|
| 127 | + $this->_columnIndex=TPropertyValue::ensureInteger($value); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | public function setResultMapping($value) |
| 142 | 142 | { |
| 143 | - $this->_nestedResultMapName = $value; |
|
| 143 | + $this->_nestedResultMapName=$value; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | */ |
| 157 | 157 | public function setNestedResultMap($value) |
| 158 | 158 | { |
| 159 | - $this->_nestedResultMap = $value; |
|
| 159 | + $this->_nestedResultMap=$value; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | */ |
| 173 | 173 | public function setType($value) |
| 174 | 174 | { |
| 175 | - $this->_valueType = $value; |
|
| 175 | + $this->_valueType=$value; |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | /** |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | */ |
| 189 | 189 | public function setTypeHandler($value) |
| 190 | 190 | { |
| 191 | - $this->_typeHandler = $value; |
|
| 191 | + $this->_typeHandler=$value; |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | /** |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | */ |
| 207 | 207 | public function setSelect($value) |
| 208 | 208 | { |
| 209 | - $this->_select = $value; |
|
| 209 | + $this->_select=$value; |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | */ |
| 223 | 223 | public function setLazyLoad($value) |
| 224 | 224 | { |
| 225 | - $this->_isLazyLoad = TPropertyValue::ensureBoolean($value,false); |
|
| 225 | + $this->_isLazyLoad=TPropertyValue::ensureBoolean($value, false); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | /** |
@@ -231,17 +231,17 @@ discard block |
||
| 231 | 231 | * @param array result row |
| 232 | 232 | * @return mixed property value. |
| 233 | 233 | */ |
| 234 | - public function getPropertyValue($registry,$row) |
|
| 234 | + public function getPropertyValue($registry, $row) |
|
| 235 | 235 | { |
| 236 | - $value = null; |
|
| 237 | - $index = $this->getColumnIndex(); |
|
| 238 | - $name = $this->getColumn(); |
|
| 236 | + $value=null; |
|
| 237 | + $index=$this->getColumnIndex(); |
|
| 238 | + $name=$this->getColumn(); |
|
| 239 | 239 | if($index > 0 && isset($row[$index])) |
| 240 | - $value = $this->getTypedValue($registry,$row[$index]); |
|
| 240 | + $value=$this->getTypedValue($registry, $row[$index]); |
|
| 241 | 241 | else if(isset($row[$name])) |
| 242 | - $value = $this->getTypedValue($registry,$row[$name]); |
|
| 242 | + $value=$this->getTypedValue($registry, $row[$name]); |
|
| 243 | 243 | if(($value===null) && ($this->getNullValue()!==null)) |
| 244 | - $value = $this->getTypedValue($registry,$this->getNullValue()); |
|
| 244 | + $value=$this->getTypedValue($registry, $this->getNullValue()); |
|
| 245 | 245 | return $value; |
| 246 | 246 | } |
| 247 | 247 | |
@@ -250,9 +250,9 @@ discard block |
||
| 250 | 250 | * @param mixed raw property value |
| 251 | 251 | * @return mixed property value casted to specific type. |
| 252 | 252 | */ |
| 253 | - protected function getTypedValue($registry,$value) |
|
| 253 | + protected function getTypedValue($registry, $value) |
|
| 254 | 254 | { |
| 255 | - if(($handler = $this->createTypeHandler($registry))!==null) |
|
| 255 | + if(($handler=$this->createTypeHandler($registry))!==null) |
|
| 256 | 256 | return $handler->getResult($value); |
| 257 | 257 | else |
| 258 | 258 | return $registry->convertToType($this->getType(), $value); |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | $type=$this->getTypeHandler() ? $this->getTypeHandler() : $this->getType(); |
| 269 | 269 | $handler=$registry->getTypeHandler($type); |
| 270 | 270 | if($handler===null && $this->getTypeHandler()) |
| 271 | - $handler = Prado::createComponent($type); |
|
| 271 | + $handler=Prado::createComponent($type); |
|
| 272 | 272 | return $handler; |
| 273 | 273 | } |
| 274 | 274 | |
@@ -278,17 +278,17 @@ discard block |
||
| 278 | 278 | */ |
| 279 | 279 | protected function getPropertyValueType() |
| 280 | 280 | { |
| 281 | - if(class_exists($type = $this->getType(), false)) //NO force autoloading |
|
| 281 | + if(class_exists($type=$this->getType(), false)) //NO force autoloading |
|
| 282 | 282 | { |
| 283 | 283 | if($type==='TList') |
| 284 | 284 | return self::LIST_TYPE; |
| 285 | - $class = new ReflectionClass($type); |
|
| 285 | + $class=new ReflectionClass($type); |
|
| 286 | 286 | if($class->isSubclassOf('TList')) |
| 287 | 287 | return self::LIST_TYPE; |
| 288 | 288 | if($class->implementsInterface('ArrayAccess')) |
| 289 | 289 | return self::ARRAY_TYPE; |
| 290 | 290 | } |
| 291 | - if(strtolower($type) == 'array') |
|
| 291 | + if(strtolower($type)=='array') |
|
| 292 | 292 | return self::ARRAY_TYPE; |
| 293 | 293 | } |
| 294 | 294 | |
@@ -301,8 +301,8 @@ discard block |
||
| 301 | 301 | public function instanceOfListType($target) |
| 302 | 302 | { |
| 303 | 303 | if($this->getType()===null) |
| 304 | - return TPropertyAccess::get($target,$this->getProperty()) instanceof TList; |
|
| 305 | - return $this->getPropertyValueType() == self::LIST_TYPE; |
|
| 304 | + return TPropertyAccess::get($target, $this->getProperty()) instanceof TList; |
|
| 305 | + return $this->getPropertyValueType()==self::LIST_TYPE; |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | /** |
@@ -315,28 +315,28 @@ discard block |
||
| 315 | 315 | { |
| 316 | 316 | if($this->getType()===null) |
| 317 | 317 | { |
| 318 | - $prop = TPropertyAccess::get($target,$this->getProperty()); |
|
| 318 | + $prop=TPropertyAccess::get($target, $this->getProperty()); |
|
| 319 | 319 | if(is_object($prop)) |
| 320 | 320 | return $prop instanceof ArrayAccess; |
| 321 | 321 | return is_array($prop); |
| 322 | 322 | } |
| 323 | - return $this->getPropertyValueType() == self::ARRAY_TYPE; |
|
| 323 | + return $this->getPropertyValueType()==self::ARRAY_TYPE; |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | public function __sleep() |
| 327 | 327 | { |
| 328 | - $exprops = array(); $cn = 'TResultProperty'; |
|
| 329 | - if ($this->_nullValue===null) $exprops[] = "\0$cn\0_nullValue"; |
|
| 330 | - if ($this->_propertyName===null) $exprops[] = "\0$cn\0_propertyNama"; |
|
| 331 | - if ($this->_columnName===null) $exprops[] = "\0$cn\0_columnName"; |
|
| 332 | - if ($this->_columnIndex==-1) $exprops[] = "\0$cn\0_columnIndex"; |
|
| 333 | - if ($this->_nestedResultMapName===null) $exprops[] = "\0$cn\0_nestedResultMapName"; |
|
| 334 | - if ($this->_nestedResultMap===null) $exprops[] = "\0$cn\0_nestedResultMap"; |
|
| 335 | - if ($this->_valueType===null) $exprops[] = "\0$cn\0_valueType"; |
|
| 336 | - if ($this->_typeHandler===null) $exprops[] = "\0$cn\0_typeHandler"; |
|
| 337 | - if ($this->_isLazyLoad===false) $exprops[] = "\0$cn\0_isLazyLoad"; |
|
| 338 | - if ($this->_select===null) $exprops[] = "\0$cn\0_select"; |
|
| 339 | - return array_diff(parent::__sleep(),$exprops); |
|
| 328 | + $exprops=array(); $cn='TResultProperty'; |
|
| 329 | + if($this->_nullValue===null) $exprops[]="\0$cn\0_nullValue"; |
|
| 330 | + if($this->_propertyName===null) $exprops[]="\0$cn\0_propertyNama"; |
|
| 331 | + if($this->_columnName===null) $exprops[]="\0$cn\0_columnName"; |
|
| 332 | + if($this->_columnIndex==-1) $exprops[]="\0$cn\0_columnIndex"; |
|
| 333 | + if($this->_nestedResultMapName===null) $exprops[]="\0$cn\0_nestedResultMapName"; |
|
| 334 | + if($this->_nestedResultMap===null) $exprops[]="\0$cn\0_nestedResultMap"; |
|
| 335 | + if($this->_valueType===null) $exprops[]="\0$cn\0_valueType"; |
|
| 336 | + if($this->_typeHandler===null) $exprops[]="\0$cn\0_typeHandler"; |
|
| 337 | + if($this->_isLazyLoad===false) $exprops[]="\0$cn\0_isLazyLoad"; |
|
| 338 | + if($this->_select===null) $exprops[]="\0$cn\0_select"; |
|
| 339 | + return array_diff(parent::__sleep(), $exprops); |
|
| 340 | 340 | } |
| 341 | 341 | } |
| 342 | 342 | |
@@ -268,6 +268,7 @@ |
||
| 268 | 268 | * @param TSqlMapTypeHandlerRegistry type handler registry |
| 269 | 269 | * @param string result class name. |
| 270 | 270 | * @param array result data. |
| 271 | + * @param string $type |
|
| 271 | 272 | * @return mixed result object. |
| 272 | 273 | */ |
| 273 | 274 | protected function createInstanceOf($registry,$type,$row=null) |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | public function setParameterMap($value) |
| 75 | 75 | { |
| 76 | - $this->_parameterMapName = $value; |
|
| 76 | + $this->_parameterMapName=$value; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public function setParameterClass($value) |
| 94 | 94 | { |
| 95 | - $this->_parameterClassName = $value; |
|
| 95 | + $this->_parameterClassName=$value; |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | */ |
| 111 | 111 | public function setResultMap($value) |
| 112 | 112 | { |
| 113 | - $this->_resultMapName = $value; |
|
| 113 | + $this->_resultMapName=$value; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | */ |
| 132 | 132 | public function setResultClass($value) |
| 133 | 133 | { |
| 134 | - $this->_resultClassName = $value; |
|
| 134 | + $this->_resultClassName=$value; |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | public function setCacheModel($value) |
| 149 | 149 | { |
| 150 | - $this->_cacheModelName = $value; |
|
| 150 | + $this->_cacheModelName=$value; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | /** |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | public function setCache($value) |
| 165 | 165 | { |
| 166 | - $this->_cache = $value; |
|
| 166 | + $this->_cache=$value; |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /** |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | public function setSqlText($value) |
| 181 | 181 | { |
| 182 | - $this->_SQL = $value; |
|
| 182 | + $this->_SQL=$value; |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | /** |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | */ |
| 197 | 197 | public function setListClass($value) |
| 198 | 198 | { |
| 199 | - $this->_listClass = $value; |
|
| 199 | + $this->_listClass=$value; |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | /** |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | */ |
| 213 | 213 | public function setExtends($value) |
| 214 | 214 | { |
| 215 | - $this->_extendStatement = $value; |
|
| 215 | + $this->_extendStatement=$value; |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | */ |
| 239 | 239 | public function setInlineParameterMap($map) |
| 240 | 240 | { |
| 241 | - $this->_parameterMap = $map; |
|
| 241 | + $this->_parameterMap=$map; |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | /** |
@@ -247,9 +247,9 @@ discard block |
||
| 247 | 247 | public function initialize($manager) |
| 248 | 248 | { |
| 249 | 249 | if(strlen($this->_resultMapName) > 0) |
| 250 | - $this->_resultMap = $manager->getResultMap($this->_resultMapName); |
|
| 250 | + $this->_resultMap=$manager->getResultMap($this->_resultMapName); |
|
| 251 | 251 | if(strlen($this->_parameterMapName) > 0) |
| 252 | - $this->_parameterMap = $manager->getParameterMap($this->_parameterMapName); |
|
| 252 | + $this->_parameterMap=$manager->getParameterMap($this->_parameterMapName); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | /** |
@@ -258,8 +258,8 @@ discard block |
||
| 258 | 258 | */ |
| 259 | 259 | public function createInstanceOfListClass($registry) |
| 260 | 260 | { |
| 261 | - if(strlen($type = $this->getListClass()) > 0) |
|
| 262 | - return $this->createInstanceOf($registry,$type); |
|
| 261 | + if(strlen($type=$this->getListClass()) > 0) |
|
| 262 | + return $this->createInstanceOf($registry, $type); |
|
| 263 | 263 | return array(); |
| 264 | 264 | } |
| 265 | 265 | |
@@ -270,9 +270,9 @@ discard block |
||
| 270 | 270 | * @param array result data. |
| 271 | 271 | * @return mixed result object. |
| 272 | 272 | */ |
| 273 | - protected function createInstanceOf($registry,$type,$row=null) |
|
| 273 | + protected function createInstanceOf($registry, $type, $row=null) |
|
| 274 | 274 | { |
| 275 | - $handler = $registry->getTypeHandler($type); |
|
| 275 | + $handler=$registry->getTypeHandler($type); |
|
| 276 | 276 | if($handler!==null) |
| 277 | 277 | return $handler->createNewInstance($row); |
| 278 | 278 | else |
@@ -285,30 +285,30 @@ discard block |
||
| 285 | 285 | * @param array result data. |
| 286 | 286 | * @return mixed result object. |
| 287 | 287 | */ |
| 288 | - public function createInstanceOfResultClass($registry,$row) |
|
| 288 | + public function createInstanceOfResultClass($registry, $row) |
|
| 289 | 289 | { |
| 290 | - if(strlen($type= $this->getResultClass()) > 0) |
|
| 291 | - return $this->createInstanceOf($registry,$type,$row); |
|
| 290 | + if(strlen($type=$this->getResultClass()) > 0) |
|
| 291 | + return $this->createInstanceOf($registry, $type, $row); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | public function __sleep() |
| 295 | 295 | { |
| 296 | - $cn = __CLASS__; |
|
| 297 | - $exprops = array("\0$cn\0_resultMap"); |
|
| 298 | - if (!$this->_parameterMapName) $exprops[] = "\0$cn\0_parameterMapName"; |
|
| 299 | - if (!$this->_parameterMap) $exprops[] = "\0$cn\0_parameterMap"; |
|
| 300 | - if (!$this->_parameterClassName) $exprops[] = "\0$cn\0_parameterClassName"; |
|
| 301 | - if (!$this->_resultMapName) $exprops[] = "\0$cn\0_resultMapName"; |
|
| 302 | - if (!$this->_resultMap) $exprops[] = "\0$cn\0_resultMap"; |
|
| 303 | - if (!$this->_resultClassName) $exprops[] = "\0$cn\0_resultClassName"; |
|
| 304 | - if (!$this->_cacheModelName) $exprops[] = "\0$cn\0_cacheModelName"; |
|
| 305 | - if (!$this->_SQL) $exprops[] = "\0$cn\0_SQL"; |
|
| 306 | - if (!$this->_listClass) $exprops[] = "\0$cn\0_listClass"; |
|
| 307 | - if (!$this->_typeHandler) $exprops[] = "\0$cn\0_typeHandler"; |
|
| 308 | - if (!$this->_extendStatement) $exprops[] = "\0$cn\0_extendStatement"; |
|
| 309 | - if (!$this->_cache) $exprops[] = "\0$cn\0_cache"; |
|
| 296 | + $cn=__CLASS__; |
|
| 297 | + $exprops=array("\0$cn\0_resultMap"); |
|
| 298 | + if(!$this->_parameterMapName) $exprops[]="\0$cn\0_parameterMapName"; |
|
| 299 | + if(!$this->_parameterMap) $exprops[]="\0$cn\0_parameterMap"; |
|
| 300 | + if(!$this->_parameterClassName) $exprops[]="\0$cn\0_parameterClassName"; |
|
| 301 | + if(!$this->_resultMapName) $exprops[]="\0$cn\0_resultMapName"; |
|
| 302 | + if(!$this->_resultMap) $exprops[]="\0$cn\0_resultMap"; |
|
| 303 | + if(!$this->_resultClassName) $exprops[]="\0$cn\0_resultClassName"; |
|
| 304 | + if(!$this->_cacheModelName) $exprops[]="\0$cn\0_cacheModelName"; |
|
| 305 | + if(!$this->_SQL) $exprops[]="\0$cn\0_SQL"; |
|
| 306 | + if(!$this->_listClass) $exprops[]="\0$cn\0_listClass"; |
|
| 307 | + if(!$this->_typeHandler) $exprops[]="\0$cn\0_typeHandler"; |
|
| 308 | + if(!$this->_extendStatement) $exprops[]="\0$cn\0_extendStatement"; |
|
| 309 | + if(!$this->_cache) $exprops[]="\0$cn\0_cache"; |
|
| 310 | 310 | |
| 311 | - return array_diff(parent::__sleep(),$exprops); |
|
| 311 | + return array_diff(parent::__sleep(), $exprops); |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | } |
@@ -324,8 +324,8 @@ discard block |
||
| 324 | 324 | { |
| 325 | 325 | private $_generate; |
| 326 | 326 | |
| 327 | - public function getGenerate(){ return $this->_generate; } |
|
| 328 | - public function setGenerate($value){ $this->_generate = $value; } |
|
| 327 | + public function getGenerate() { return $this->_generate; } |
|
| 328 | + public function setGenerate($value) { $this->_generate=$value; } |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | /** |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | */ |
| 356 | 356 | public function setSelectKey($value) |
| 357 | 357 | { |
| 358 | - $this->_selectKey = $value; |
|
| 358 | + $this->_selectKey=$value; |
|
| 359 | 359 | } |
| 360 | 360 | } |
| 361 | 361 | |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | */ |
| 391 | 391 | class TSqlMapSelectKey extends TSqlMapStatement |
| 392 | 392 | { |
| 393 | - private $_type = 'post'; |
|
| 393 | + private $_type='post'; |
|
| 394 | 394 | private $_property; |
| 395 | 395 | |
| 396 | 396 | /** |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | */ |
| 407 | 407 | public function setType($value) |
| 408 | 408 | { |
| 409 | - $this->_type = strtolower($value) == 'post' ? 'post' : 'pre'; |
|
| 409 | + $this->_type=strtolower($value)=='post' ? 'post' : 'pre'; |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | /** |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | */ |
| 423 | 423 | public function setProperty($value) |
| 424 | 424 | { |
| 425 | - $this->_property = $value; |
|
| 425 | + $this->_property=$value; |
|
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | /** |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | */ |
| 439 | 439 | public function getIsAfter() |
| 440 | 440 | { |
| 441 | - return $this->_type == 'post'; |
|
| 441 | + return $this->_type=='post'; |
|
| 442 | 442 | } |
| 443 | 443 | } |
| 444 | 444 | |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * Create an instance of an object give by the attribute named 'class' in the |
| 24 | 24 | * node and set the properties on the object given by attribute names and values. |
| 25 | 25 | * @param SimpleXmlNode property node |
| 26 | - * @return Object new instance of class with class name given by 'class' attribute value. |
|
| 26 | + * @return TComponent new instance of class with class name given by 'class' attribute value. |
|
| 27 | 27 | */ |
| 28 | 28 | protected function createObjectFromNode($node) |
| 29 | 29 | { |
@@ -44,6 +44,7 @@ discard block |
||
| 44 | 44 | * @param Object object instance |
| 45 | 45 | * @param SimpleXmlNode property node |
| 46 | 46 | * @param array exception property name |
| 47 | + * @param TComponent $obj |
|
| 47 | 48 | */ |
| 48 | 49 | protected function setObjectPropFromNode($obj,$node,$except=array()) |
| 49 | 50 | { |
@@ -65,6 +66,8 @@ discard block |
||
| 65 | 66 | * Gets the filename relative to the basefile. |
| 66 | 67 | * @param string base filename |
| 67 | 68 | * @param string relative filename |
| 69 | + * @param string $basefile |
|
| 70 | + * @param string $resource |
|
| 68 | 71 | * @return string absolute filename. |
| 69 | 72 | */ |
| 70 | 73 | protected function getAbsoluteFilePath($basefile,$resource) |
@@ -98,9 +101,10 @@ discard block |
||
| 98 | 101 | |
| 99 | 102 | /** |
| 100 | 103 | * Get element node by ID value (try for attribute name ID as case insensitive). |
| 101 | - * @param SimpleXmlDocument $document |
|
| 104 | + * @param SimpleXMLElement $document |
|
| 102 | 105 | * @param string tag name. |
| 103 | 106 | * @param string id value. |
| 107 | + * @param string $tag |
|
| 104 | 108 | * @return SimpleXmlElement node if found, null otherwise. |
| 105 | 109 | */ |
| 106 | 110 | protected function getElementByIdValue($document, $tag, $value) |
@@ -146,6 +150,7 @@ discard block |
||
| 146 | 150 | |
| 147 | 151 | /** |
| 148 | 152 | * @param TSqlMapManager manager instance. |
| 153 | + * @param TSqlMapManager $manager |
|
| 149 | 154 | */ |
| 150 | 155 | public function __construct($manager) |
| 151 | 156 | { |
@@ -524,6 +529,7 @@ discard block |
||
| 524 | 529 | * in the sql text. Extracts inline parameter maps. |
| 525 | 530 | * @param TSqlMapStatement mapped statement. |
| 526 | 531 | * @param SimpleXmlElement statement node. |
| 532 | + * @param TSqlMapStatement $statement |
|
| 527 | 533 | */ |
| 528 | 534 | protected function processSqlStatement($statement, $node) |
| 529 | 535 | { |
@@ -547,6 +553,7 @@ discard block |
||
| 547 | 553 | * @param TSqlMapStatement statement object. |
| 548 | 554 | * @param string sql text |
| 549 | 555 | * @param SimpleXmlElement statement node. |
| 556 | + * @param string $sqlStatement |
|
| 550 | 557 | */ |
| 551 | 558 | protected function applyInlineParameterMap($statement, $sqlStatement, $node) |
| 552 | 559 | { |
@@ -644,6 +651,7 @@ discard block |
||
| 644 | 651 | /** |
| 645 | 652 | * Load the selectKey statement from xml mapping. |
| 646 | 653 | * @param SimpleXmlElement selectkey node |
| 654 | + * @param TSqlMapInsert $insert |
|
| 647 | 655 | */ |
| 648 | 656 | protected function loadSelectKeyTag($insert, $node) |
| 649 | 657 | { |
@@ -734,6 +742,7 @@ discard block |
||
| 734 | 742 | * Load the flush interval |
| 735 | 743 | * @param TSqlMapCacheModel cache model |
| 736 | 744 | * @param SimpleXmlElement cache node |
| 745 | + * @param TSqlMapCacheModel $cacheModel |
|
| 737 | 746 | */ |
| 738 | 747 | protected function loadFlushInterval($cacheModel, $node) |
| 739 | 748 | { |
@@ -769,6 +778,7 @@ discard block |
||
| 769 | 778 | * @param TSqlMapCacheModel cache model |
| 770 | 779 | * @param SimpleXmlElement parent node. |
| 771 | 780 | * @param SimpleXmlElement flush node. |
| 781 | + * @param TSqlMapCacheModel $cacheModel |
|
| 772 | 782 | */ |
| 773 | 783 | protected function loadFlushOnCache($cacheModel,$parent,$node) |
| 774 | 784 | { |
@@ -58,8 +58,7 @@ |
||
| 58 | 58 | if ($this->sourcepath === NULL) |
| 59 | 59 | { |
| 60 | 60 | $this->sourcepath = $sourcepath; |
| 61 | - } |
|
| 62 | - else |
|
| 61 | + } else |
|
| 63 | 62 | { |
| 64 | 63 | $this->sourcepath->append($sourcepath); |
| 65 | 64 | } |
@@ -29,8 +29,8 @@ discard block |
||
| 29 | 29 | { |
| 30 | 30 | if(isset($node['class'])) |
| 31 | 31 | { |
| 32 | - $obj = Prado::createComponent((string)$node['class']); |
|
| 33 | - $this->setObjectPropFromNode($obj,$node,array('class')); |
|
| 32 | + $obj=Prado::createComponent((string) $node['class']); |
|
| 33 | + $this->setObjectPropFromNode($obj, $node, array('class')); |
|
| 34 | 34 | return $obj; |
| 35 | 35 | } |
| 36 | 36 | throw new TSqlMapConfigurationException( |
@@ -45,14 +45,14 @@ discard block |
||
| 45 | 45 | * @param SimpleXmlNode property node |
| 46 | 46 | * @param array exception property name |
| 47 | 47 | */ |
| 48 | - protected function setObjectPropFromNode($obj,$node,$except=array()) |
|
| 48 | + protected function setObjectPropFromNode($obj, $node, $except=array()) |
|
| 49 | 49 | { |
| 50 | 50 | foreach($node->attributes() as $name=>$value) |
| 51 | 51 | { |
| 52 | - if(!in_array($name,$except)) |
|
| 52 | + if(!in_array($name, $except)) |
|
| 53 | 53 | { |
| 54 | 54 | if($obj->canSetProperty($name)) |
| 55 | - $obj->{$name} = (string)$value; |
|
| 55 | + $obj->{$name}=(string) $value; |
|
| 56 | 56 | else |
| 57 | 57 | throw new TSqlMapConfigurationException( |
| 58 | 58 | 'sqlmap_invalid_property', $name, get_class($obj), |
@@ -67,12 +67,12 @@ discard block |
||
| 67 | 67 | * @param string relative filename |
| 68 | 68 | * @return string absolute filename. |
| 69 | 69 | */ |
| 70 | - protected function getAbsoluteFilePath($basefile,$resource) |
|
| 70 | + protected function getAbsoluteFilePath($basefile, $resource) |
|
| 71 | 71 | { |
| 72 | - $basedir = dirname($basefile); |
|
| 73 | - $file = realpath($basedir.DIRECTORY_SEPARATOR.$resource); |
|
| 72 | + $basedir=dirname($basefile); |
|
| 73 | + $file=realpath($basedir.DIRECTORY_SEPARATOR.$resource); |
|
| 74 | 74 | if(!is_string($file) || !is_file($file)) |
| 75 | - $file = realpath($resource); |
|
| 75 | + $file=realpath($resource); |
|
| 76 | 76 | if(is_string($file) && is_file($file)) |
| 77 | 77 | return $file; |
| 78 | 78 | else |
@@ -85,10 +85,10 @@ discard block |
||
| 85 | 85 | * @param string filename. |
| 86 | 86 | * @return SimpleXmlElement xml document. |
| 87 | 87 | */ |
| 88 | - protected function loadXmlDocument($filename,TSqlMapXmlConfiguration $config) |
|
| 88 | + protected function loadXmlDocument($filename, TSqlMapXmlConfiguration $config) |
|
| 89 | 89 | { |
| 90 | - if( strpos($filename, '${') !== false) |
|
| 91 | - $filename = $config->replaceProperties($filename); |
|
| 90 | + if(strpos($filename, '${')!==false) |
|
| 91 | + $filename=$config->replaceProperties($filename); |
|
| 92 | 92 | |
| 93 | 93 | if(!is_file($filename)) |
| 94 | 94 | throw new TSqlMapConfigurationException( |
@@ -106,9 +106,9 @@ discard block |
||
| 106 | 106 | protected function getElementByIdValue($document, $tag, $value) |
| 107 | 107 | { |
| 108 | 108 | //hack to allow upper case and lower case attribute names. |
| 109 | - foreach(array('id','ID','Id', 'iD') as $id) |
|
| 109 | + foreach(array('id', 'ID', 'Id', 'iD') as $id) |
|
| 110 | 110 | { |
| 111 | - $xpath = "//{$tag}[@{$id}='{$value}']"; |
|
| 111 | + $xpath="//{$tag}[@{$id}='{$value}']"; |
|
| 112 | 112 | foreach($document->xpath($xpath) as $node) |
| 113 | 113 | return $node; |
| 114 | 114 | } |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | public function configure($filename=null) |
| 170 | 170 | { |
| 171 | 171 | $this->_configFile=$filename; |
| 172 | - $document = $this->loadXmlDocument($filename,$this); |
|
| 172 | + $document=$this->loadXmlDocument($filename, $this); |
|
| 173 | 173 | |
| 174 | 174 | foreach($document->xpath('//property') as $property) |
| 175 | 175 | $this->loadGlobalProperty($property); |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | $this->loadDatabaseConnection($conn); |
| 182 | 182 | |
| 183 | 183 | //try to load configuration in the current config file. |
| 184 | - $mapping = new TSqlMapXmlMappingConfiguration($this); |
|
| 184 | + $mapping=new TSqlMapXmlMappingConfiguration($this); |
|
| 185 | 185 | $mapping->configure($filename); |
| 186 | 186 | |
| 187 | 187 | foreach($document->xpath('//sqlMap') as $sqlmap) |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | */ |
| 198 | 198 | protected function loadGlobalProperty($node) |
| 199 | 199 | { |
| 200 | - $this->_properties[(string)$node['name']] = (string)$node['value']; |
|
| 200 | + $this->_properties[(string) $node['name']]=(string) $node['value']; |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | */ |
| 207 | 207 | protected function loadTypeHandler($node) |
| 208 | 208 | { |
| 209 | - $handler = $this->createObjectFromNode($node); |
|
| 209 | + $handler=$this->createObjectFromNode($node); |
|
| 210 | 210 | $this->_manager->getTypeHandlers()->registerTypeHandler($handler); |
| 211 | 211 | } |
| 212 | 212 | |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | protected function loadDatabaseConnection($node) |
| 218 | 218 | { |
| 219 | - $conn = $this->createObjectFromNode($node); |
|
| 219 | + $conn=$this->createObjectFromNode($node); |
|
| 220 | 220 | $this->_manager->setDbConnection($conn); |
| 221 | 221 | } |
| 222 | 222 | |
@@ -226,13 +226,13 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | protected function loadSqlMappingFiles($node) |
| 228 | 228 | { |
| 229 | - if(strlen($resource = (string)$node['resource']) > 0) |
|
| 229 | + if(strlen($resource=(string) $node['resource']) > 0) |
|
| 230 | 230 | { |
| 231 | - if( strpos($resource, '${') !== false) |
|
| 232 | - $resource = $this->replaceProperties($resource); |
|
| 231 | + if(strpos($resource, '${')!==false) |
|
| 232 | + $resource=$this->replaceProperties($resource); |
|
| 233 | 233 | |
| 234 | - $mapping = new TSqlMapXmlMappingConfiguration($this); |
|
| 235 | - $filename = $this->getAbsoluteFilePath($this->_configFile, $resource); |
|
| 234 | + $mapping=new TSqlMapXmlMappingConfiguration($this); |
|
| 235 | + $filename=$this->getAbsoluteFilePath($this->_configFile, $resource); |
|
| 236 | 236 | $mapping->configure($filename); |
| 237 | 237 | } |
| 238 | 238 | } |
@@ -242,12 +242,12 @@ discard block |
||
| 242 | 242 | */ |
| 243 | 243 | protected function resolveResultMapping() |
| 244 | 244 | { |
| 245 | - $maps = $this->_manager->getResultMaps(); |
|
| 245 | + $maps=$this->_manager->getResultMaps(); |
|
| 246 | 246 | foreach($maps as $entry) |
| 247 | 247 | { |
| 248 | 248 | foreach($entry->getColumns() as $item) |
| 249 | 249 | { |
| 250 | - $resultMap = $item->getResultMapping(); |
|
| 250 | + $resultMap=$item->getResultMapping(); |
|
| 251 | 251 | if(strlen($resultMap) > 0) |
| 252 | 252 | { |
| 253 | 253 | if($maps->contains($resultMap)) |
@@ -270,9 +270,9 @@ discard block |
||
| 270 | 270 | { |
| 271 | 271 | foreach($this->_manager->getMappedStatements() as $mappedStatement) |
| 272 | 272 | { |
| 273 | - if(strlen($model = $mappedStatement->getStatement()->getCacheModel()) > 0) |
|
| 273 | + if(strlen($model=$mappedStatement->getStatement()->getCacheModel()) > 0) |
|
| 274 | 274 | { |
| 275 | - $cache = $this->_manager->getCacheModel($model); |
|
| 275 | + $cache=$this->_manager->getCacheModel($model); |
|
| 276 | 276 | $mappedStatement->getStatement()->setCache($cache); |
| 277 | 277 | } |
| 278 | 278 | } |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | public function replaceProperties($string) |
| 288 | 288 | { |
| 289 | 289 | foreach($this->_properties as $find => $replace) |
| 290 | - $string = str_replace('${'.$find.'}', $replace, $string); |
|
| 290 | + $string=str_replace('${'.$find.'}', $replace, $string); |
|
| 291 | 291 | return $string; |
| 292 | 292 | } |
| 293 | 293 | } |
@@ -342,12 +342,12 @@ discard block |
||
| 342 | 342 | public function configure($filename) |
| 343 | 343 | { |
| 344 | 344 | $this->_configFile=$filename; |
| 345 | - $document = $this->loadXmlDocument($filename,$this->_xmlConfig); |
|
| 345 | + $document=$this->loadXmlDocument($filename, $this->_xmlConfig); |
|
| 346 | 346 | $this->_document=$document; |
| 347 | 347 | |
| 348 | 348 | static $bCacheDependencies; |
| 349 | - if($bCacheDependencies === null) |
|
| 350 | - $bCacheDependencies = true; //Prado::getApplication()->getMode() !== TApplicationMode::Performance; |
|
| 349 | + if($bCacheDependencies===null) |
|
| 350 | + $bCacheDependencies=true; //Prado::getApplication()->getMode() !== TApplicationMode::Performance; |
|
| 351 | 351 | |
| 352 | 352 | if($bCacheDependencies) |
| 353 | 353 | $this->_manager->getCacheDependencies() |
@@ -390,14 +390,14 @@ discard block |
||
| 390 | 390 | */ |
| 391 | 391 | protected function loadResultMap($node) |
| 392 | 392 | { |
| 393 | - $resultMap = $this->createResultMap($node); |
|
| 393 | + $resultMap=$this->createResultMap($node); |
|
| 394 | 394 | |
| 395 | 395 | //find extended result map. |
| 396 | - if(strlen($extendMap = $resultMap->getExtends()) > 0) |
|
| 396 | + if(strlen($extendMap=$resultMap->getExtends()) > 0) |
|
| 397 | 397 | { |
| 398 | 398 | if(!$this->_manager->getResultMaps()->contains($extendMap)) |
| 399 | 399 | { |
| 400 | - $extendNode=$this->getElementByIdValue($this->_document,'resultMap',$extendMap); |
|
| 400 | + $extendNode=$this->getElementByIdValue($this->_document, 'resultMap', $extendMap); |
|
| 401 | 401 | if($extendNode!==null) |
| 402 | 402 | $this->loadResultMap($extendNode); |
| 403 | 403 | } |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | throw new TSqlMapConfigurationException( |
| 407 | 407 | 'sqlmap_unable_to_find_parent_result_map', $node, $this->_configFile, $extendMap); |
| 408 | 408 | |
| 409 | - $superMap = $this->_manager->getResultMap($extendMap); |
|
| 409 | + $superMap=$this->_manager->getResultMap($extendMap); |
|
| 410 | 410 | $resultMap->getColumns()->mergeWith($superMap->getColumns()); |
| 411 | 411 | } |
| 412 | 412 | |
@@ -423,22 +423,22 @@ discard block |
||
| 423 | 423 | */ |
| 424 | 424 | protected function createResultMap($node) |
| 425 | 425 | { |
| 426 | - $resultMap = new TResultMap(); |
|
| 427 | - $this->setObjectPropFromNode($resultMap,$node); |
|
| 426 | + $resultMap=new TResultMap(); |
|
| 427 | + $this->setObjectPropFromNode($resultMap, $node); |
|
| 428 | 428 | |
| 429 | 429 | //result nodes |
| 430 | 430 | foreach($node->result as $result) |
| 431 | 431 | { |
| 432 | - $property = new TResultProperty($resultMap); |
|
| 433 | - $this->setObjectPropFromNode($property,$result); |
|
| 432 | + $property=new TResultProperty($resultMap); |
|
| 433 | + $this->setObjectPropFromNode($property, $result); |
|
| 434 | 434 | $resultMap->addResultProperty($property); |
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | //create the discriminator |
| 438 | - $discriminator = null; |
|
| 438 | + $discriminator=null; |
|
| 439 | 439 | if(isset($node->discriminator)) |
| 440 | 440 | { |
| 441 | - $discriminator = new TDiscriminator(); |
|
| 441 | + $discriminator=new TDiscriminator(); |
|
| 442 | 442 | $this->setObjectPropFromNode($discriminator, $node->discriminator); |
| 443 | 443 | $discriminator->initMapping($resultMap); |
| 444 | 444 | } |
@@ -447,9 +447,9 @@ discard block |
||
| 447 | 447 | { |
| 448 | 448 | if($discriminator===null) |
| 449 | 449 | throw new TSqlMapConfigurationException( |
| 450 | - 'sqlmap_undefined_discriminator', $node, $this->_configFile,$subMapNode); |
|
| 451 | - $subMap = new TSubMap; |
|
| 452 | - $this->setObjectPropFromNode($subMap,$subMapNode); |
|
| 450 | + 'sqlmap_undefined_discriminator', $node, $this->_configFile, $subMapNode); |
|
| 451 | + $subMap=new TSubMap; |
|
| 452 | + $this->setObjectPropFromNode($subMap, $subMapNode); |
|
| 453 | 453 | $discriminator->addSubMap($subMap); |
| 454 | 454 | } |
| 455 | 455 | |
@@ -466,24 +466,24 @@ discard block |
||
| 466 | 466 | */ |
| 467 | 467 | protected function loadParameterMap($node) |
| 468 | 468 | { |
| 469 | - $parameterMap = $this->createParameterMap($node); |
|
| 469 | + $parameterMap=$this->createParameterMap($node); |
|
| 470 | 470 | |
| 471 | - if(strlen($extendMap = $parameterMap->getExtends()) > 0) |
|
| 471 | + if(strlen($extendMap=$parameterMap->getExtends()) > 0) |
|
| 472 | 472 | { |
| 473 | 473 | if(!$this->_manager->getParameterMaps()->contains($extendMap)) |
| 474 | 474 | { |
| 475 | - $extendNode=$this->getElementByIdValue($this->_document,'parameterMap',$extendMap); |
|
| 475 | + $extendNode=$this->getElementByIdValue($this->_document, 'parameterMap', $extendMap); |
|
| 476 | 476 | if($extendNode!==null) |
| 477 | 477 | $this->loadParameterMap($extendNode); |
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | if(!$this->_manager->getParameterMaps()->contains($extendMap)) |
| 481 | 481 | throw new TSqlMapConfigurationException( |
| 482 | - 'sqlmap_unable_to_find_parent_parameter_map', $node, $this->_configFile,$extendMap); |
|
| 483 | - $superMap = $this->_manager->getParameterMap($extendMap); |
|
| 484 | - $index = 0; |
|
| 482 | + 'sqlmap_unable_to_find_parent_parameter_map', $node, $this->_configFile, $extendMap); |
|
| 483 | + $superMap=$this->_manager->getParameterMap($extendMap); |
|
| 484 | + $index=0; |
|
| 485 | 485 | foreach($superMap->getPropertyNames() as $propertyName) |
| 486 | - $parameterMap->insertProperty($index++,$superMap->getProperty($propertyName)); |
|
| 486 | + $parameterMap->insertProperty($index++, $superMap->getProperty($propertyName)); |
|
| 487 | 487 | } |
| 488 | 488 | $this->_manager->addParameterMap($parameterMap); |
| 489 | 489 | } |
@@ -495,12 +495,12 @@ discard block |
||
| 495 | 495 | */ |
| 496 | 496 | protected function createParameterMap($node) |
| 497 | 497 | { |
| 498 | - $parameterMap = new TParameterMap(); |
|
| 499 | - $this->setObjectPropFromNode($parameterMap,$node); |
|
| 498 | + $parameterMap=new TParameterMap(); |
|
| 499 | + $this->setObjectPropFromNode($parameterMap, $node); |
|
| 500 | 500 | foreach($node->parameter as $parameter) |
| 501 | 501 | { |
| 502 | - $property = new TParameterProperty(); |
|
| 503 | - $this->setObjectPropFromNode($property,$parameter); |
|
| 502 | + $property=new TParameterProperty(); |
|
| 503 | + $this->setObjectPropFromNode($property, $parameter); |
|
| 504 | 504 | $parameterMap->addProperty($property); |
| 505 | 505 | } |
| 506 | 506 | return $parameterMap; |
@@ -512,10 +512,10 @@ discard block |
||
| 512 | 512 | */ |
| 513 | 513 | protected function loadStatementTag($node) |
| 514 | 514 | { |
| 515 | - $statement = new TSqlMapStatement(); |
|
| 516 | - $this->setObjectPropFromNode($statement,$node); |
|
| 515 | + $statement=new TSqlMapStatement(); |
|
| 516 | + $this->setObjectPropFromNode($statement, $node); |
|
| 517 | 517 | $this->processSqlStatement($statement, $node); |
| 518 | - $mappedStatement = new TMappedStatement($this->_manager, $statement); |
|
| 518 | + $mappedStatement=new TMappedStatement($this->_manager, $statement); |
|
| 519 | 519 | $this->_manager->addMappedStatement($mappedStatement); |
| 520 | 520 | } |
| 521 | 521 | |
@@ -527,15 +527,15 @@ discard block |
||
| 527 | 527 | */ |
| 528 | 528 | protected function processSqlStatement($statement, $node) |
| 529 | 529 | { |
| 530 | - $commandText = (string)$node; |
|
| 531 | - if(strlen($extend = $statement->getExtends()) > 0) |
|
| 530 | + $commandText=(string) $node; |
|
| 531 | + if(strlen($extend=$statement->getExtends()) > 0) |
|
| 532 | 532 | { |
| 533 | - $superNode = $this->getElementByIdValue($this->_document,'*',$extend); |
|
| 533 | + $superNode=$this->getElementByIdValue($this->_document, '*', $extend); |
|
| 534 | 534 | if($superNode!==null) |
| 535 | - $commandText = (string)$superNode . $commandText; |
|
| 535 | + $commandText=(string) $superNode.$commandText; |
|
| 536 | 536 | else |
| 537 | 537 | throw new TSqlMapConfigurationException( |
| 538 | - 'sqlmap_unable_to_find_parent_sql', $extend, $this->_configFile,$node); |
|
| 538 | + 'sqlmap_unable_to_find_parent_sql', $extend, $this->_configFile, $node); |
|
| 539 | 539 | } |
| 540 | 540 | //$commandText = $this->_xmlConfig->replaceProperties($commandText); |
| 541 | 541 | $statement->initialize($this->_manager); |
@@ -550,27 +550,27 @@ discard block |
||
| 550 | 550 | */ |
| 551 | 551 | protected function applyInlineParameterMap($statement, $sqlStatement, $node) |
| 552 | 552 | { |
| 553 | - $scope['file'] = $this->_configFile; |
|
| 554 | - $scope['node'] = $node; |
|
| 553 | + $scope['file']=$this->_configFile; |
|
| 554 | + $scope['node']=$node; |
|
| 555 | 555 | |
| 556 | - $sqlStatement=preg_replace(self::ESCAPED_INLINE_SYMBOL_REGEXP,self::INLINE_PLACEHOLDER,$sqlStatement); |
|
| 557 | - if($statement->parameterMap() === null) |
|
| 556 | + $sqlStatement=preg_replace(self::ESCAPED_INLINE_SYMBOL_REGEXP, self::INLINE_PLACEHOLDER, $sqlStatement); |
|
| 557 | + if($statement->parameterMap()===null) |
|
| 558 | 558 | { |
| 559 | 559 | // Build a Parametermap with the inline parameters. |
| 560 | 560 | // if they exist. Then delete inline infos from sqltext. |
| 561 | - $parameterParser = new TInlineParameterMapParser; |
|
| 562 | - $sqlText = $parameterParser->parse($sqlStatement, $scope); |
|
| 561 | + $parameterParser=new TInlineParameterMapParser; |
|
| 562 | + $sqlText=$parameterParser->parse($sqlStatement, $scope); |
|
| 563 | 563 | if(count($sqlText['parameters']) > 0) |
| 564 | 564 | { |
| 565 | - $map = new TParameterMap(); |
|
| 565 | + $map=new TParameterMap(); |
|
| 566 | 566 | $map->setID($statement->getID().'-InLineParameterMap'); |
| 567 | 567 | $statement->setInlineParameterMap($map); |
| 568 | 568 | foreach($sqlText['parameters'] as $property) |
| 569 | 569 | $map->addProperty($property); |
| 570 | 570 | } |
| 571 | - $sqlStatement = $sqlText['sql']; |
|
| 571 | + $sqlStatement=$sqlText['sql']; |
|
| 572 | 572 | } |
| 573 | - $sqlStatement=preg_replace('/'.self::INLINE_PLACEHOLDER.'/',self::INLINE_SYMBOL,$sqlStatement); |
|
| 573 | + $sqlStatement=preg_replace('/'.self::INLINE_PLACEHOLDER.'/', self::INLINE_SYMBOL, $sqlStatement); |
|
| 574 | 574 | |
| 575 | 575 | $this->prepareSql($statement, $sqlStatement, $node); |
| 576 | 576 | } |
@@ -582,19 +582,19 @@ discard block |
||
| 582 | 582 | * @param SimpleXmlElement statement node. |
| 583 | 583 | * @todo Extend to dynamic sql. |
| 584 | 584 | */ |
| 585 | - protected function prepareSql($statement,$sqlStatement, $node) |
|
| 585 | + protected function prepareSql($statement, $sqlStatement, $node) |
|
| 586 | 586 | { |
| 587 | - $simpleDynamic = new TSimpleDynamicParser; |
|
| 588 | - $sqlStatement=preg_replace(self::ESCAPED_SIMPLE_MARK_REGEXP,self::SIMPLE_PLACEHOLDER,$sqlStatement); |
|
| 589 | - $dynamics = $simpleDynamic->parse($sqlStatement); |
|
| 587 | + $simpleDynamic=new TSimpleDynamicParser; |
|
| 588 | + $sqlStatement=preg_replace(self::ESCAPED_SIMPLE_MARK_REGEXP, self::SIMPLE_PLACEHOLDER, $sqlStatement); |
|
| 589 | + $dynamics=$simpleDynamic->parse($sqlStatement); |
|
| 590 | 590 | if(count($dynamics['parameters']) > 0) |
| 591 | 591 | { |
| 592 | - $sql = new TSimpleDynamicSql($dynamics['parameters']); |
|
| 593 | - $sqlStatement = $dynamics['sql']; |
|
| 592 | + $sql=new TSimpleDynamicSql($dynamics['parameters']); |
|
| 593 | + $sqlStatement=$dynamics['sql']; |
|
| 594 | 594 | } |
| 595 | 595 | else |
| 596 | - $sql = new TStaticSql(); |
|
| 597 | - $sqlStatement=preg_replace('/'.self::SIMPLE_PLACEHOLDER.'/',self::SIMPLE_MARK,$sqlStatement); |
|
| 596 | + $sql=new TStaticSql(); |
|
| 597 | + $sqlStatement=preg_replace('/'.self::SIMPLE_PLACEHOLDER.'/', self::SIMPLE_MARK, $sqlStatement); |
|
| 598 | 598 | $sql->buildPreparedStatement($statement, $sqlStatement); |
| 599 | 599 | $statement->setSqlText($sql); |
| 600 | 600 | } |
@@ -605,12 +605,12 @@ discard block |
||
| 605 | 605 | */ |
| 606 | 606 | protected function loadSelectTag($node) |
| 607 | 607 | { |
| 608 | - $select = new TSqlMapSelect; |
|
| 609 | - $this->setObjectPropFromNode($select,$node); |
|
| 610 | - $this->processSqlStatement($select,$node); |
|
| 611 | - $mappedStatement = new TMappedStatement($this->_manager, $select); |
|
| 608 | + $select=new TSqlMapSelect; |
|
| 609 | + $this->setObjectPropFromNode($select, $node); |
|
| 610 | + $this->processSqlStatement($select, $node); |
|
| 611 | + $mappedStatement=new TMappedStatement($this->_manager, $select); |
|
| 612 | 612 | if(strlen($select->getCacheModel()) > 0) |
| 613 | - $mappedStatement = new TCachingStatement($mappedStatement); |
|
| 613 | + $mappedStatement=new TCachingStatement($mappedStatement); |
|
| 614 | 614 | |
| 615 | 615 | $this->_manager->addMappedStatement($mappedStatement); |
| 616 | 616 | } |
@@ -621,9 +621,9 @@ discard block |
||
| 621 | 621 | */ |
| 622 | 622 | protected function loadInsertTag($node) |
| 623 | 623 | { |
| 624 | - $insert = $this->createInsertStatement($node); |
|
| 624 | + $insert=$this->createInsertStatement($node); |
|
| 625 | 625 | $this->processSqlStatement($insert, $node); |
| 626 | - $mappedStatement = new TInsertMappedStatement($this->_manager, $insert); |
|
| 626 | + $mappedStatement=new TInsertMappedStatement($this->_manager, $insert); |
|
| 627 | 627 | $this->_manager->addMappedStatement($mappedStatement); |
| 628 | 628 | } |
| 629 | 629 | |
@@ -634,10 +634,10 @@ discard block |
||
| 634 | 634 | */ |
| 635 | 635 | protected function createInsertStatement($node) |
| 636 | 636 | { |
| 637 | - $insert = new TSqlMapInsert; |
|
| 638 | - $this->setObjectPropFromNode($insert,$node); |
|
| 637 | + $insert=new TSqlMapInsert; |
|
| 638 | + $this->setObjectPropFromNode($insert, $node); |
|
| 639 | 639 | if(isset($node->selectKey)) |
| 640 | - $this->loadSelectKeyTag($insert,$node->selectKey); |
|
| 640 | + $this->loadSelectKeyTag($insert, $node->selectKey); |
|
| 641 | 641 | return $insert; |
| 642 | 642 | } |
| 643 | 643 | |
@@ -647,13 +647,13 @@ discard block |
||
| 647 | 647 | */ |
| 648 | 648 | protected function loadSelectKeyTag($insert, $node) |
| 649 | 649 | { |
| 650 | - $selectKey = new TSqlMapSelectKey; |
|
| 651 | - $this->setObjectPropFromNode($selectKey,$node); |
|
| 650 | + $selectKey=new TSqlMapSelectKey; |
|
| 651 | + $this->setObjectPropFromNode($selectKey, $node); |
|
| 652 | 652 | $selectKey->setID($insert->getID()); |
| 653 | 653 | $selectKey->setID($insert->getID().'.SelectKey'); |
| 654 | - $this->processSqlStatement($selectKey,$node); |
|
| 654 | + $this->processSqlStatement($selectKey, $node); |
|
| 655 | 655 | $insert->setSelectKey($selectKey); |
| 656 | - $mappedStatement = new TMappedStatement($this->_manager, $selectKey); |
|
| 656 | + $mappedStatement=new TMappedStatement($this->_manager, $selectKey); |
|
| 657 | 657 | $this->_manager->addMappedStatement($mappedStatement); |
| 658 | 658 | } |
| 659 | 659 | |
@@ -663,10 +663,10 @@ discard block |
||
| 663 | 663 | */ |
| 664 | 664 | protected function loadUpdateTag($node) |
| 665 | 665 | { |
| 666 | - $update = new TSqlMapUpdate; |
|
| 667 | - $this->setObjectPropFromNode($update,$node); |
|
| 666 | + $update=new TSqlMapUpdate; |
|
| 667 | + $this->setObjectPropFromNode($update, $node); |
|
| 668 | 668 | $this->processSqlStatement($update, $node); |
| 669 | - $mappedStatement = new TUpdateMappedStatement($this->_manager, $update); |
|
| 669 | + $mappedStatement=new TUpdateMappedStatement($this->_manager, $update); |
|
| 670 | 670 | $this->_manager->addMappedStatement($mappedStatement); |
| 671 | 671 | } |
| 672 | 672 | |
@@ -676,10 +676,10 @@ discard block |
||
| 676 | 676 | */ |
| 677 | 677 | protected function loadDeleteTag($node) |
| 678 | 678 | { |
| 679 | - $delete = new TSqlMapDelete; |
|
| 680 | - $this->setObjectPropFromNode($delete,$node); |
|
| 679 | + $delete=new TSqlMapDelete; |
|
| 680 | + $this->setObjectPropFromNode($delete, $node); |
|
| 681 | 681 | $this->processSqlStatement($delete, $node); |
| 682 | - $mappedStatement = new TDeleteMappedStatement($this->_manager, $delete); |
|
| 682 | + $mappedStatement=new TDeleteMappedStatement($this->_manager, $delete); |
|
| 683 | 683 | $this->_manager->addMappedStatement($mappedStatement); |
| 684 | 684 | } |
| 685 | 685 | |
@@ -699,35 +699,35 @@ discard block |
||
| 699 | 699 | */ |
| 700 | 700 | protected function loadCacheModel($node) |
| 701 | 701 | { |
| 702 | - $cacheModel = new TSqlMapCacheModel; |
|
| 703 | - $properties = array('id','implementation'); |
|
| 702 | + $cacheModel=new TSqlMapCacheModel; |
|
| 703 | + $properties=array('id', 'implementation'); |
|
| 704 | 704 | foreach($node->attributes() as $name=>$value) |
| 705 | 705 | { |
| 706 | 706 | if(in_array(strtolower($name), $properties)) |
| 707 | - $cacheModel->{'set'.$name}((string)$value); |
|
| 707 | + $cacheModel->{'set'.$name}((string) $value); |
|
| 708 | 708 | } |
| 709 | - $cache = Prado::createComponent($cacheModel->getImplementationClass(), $cacheModel); |
|
| 710 | - $this->setObjectPropFromNode($cache,$node,$properties); |
|
| 709 | + $cache=Prado::createComponent($cacheModel->getImplementationClass(), $cacheModel); |
|
| 710 | + $this->setObjectPropFromNode($cache, $node, $properties); |
|
| 711 | 711 | |
| 712 | 712 | foreach($node->xpath('property') as $propertyNode) |
| 713 | 713 | { |
| 714 | - $name = $propertyNode->attributes()->name; |
|
| 714 | + $name=$propertyNode->attributes()->name; |
|
| 715 | 715 | if($name===null || $name==='') continue; |
| 716 | 716 | |
| 717 | - $value = $propertyNode->attributes()->value; |
|
| 717 | + $value=$propertyNode->attributes()->value; |
|
| 718 | 718 | if($value===null || $value==='') continue; |
| 719 | 719 | |
| 720 | - if( !TPropertyAccess::has($cache, $name) ) continue; |
|
| 720 | + if(!TPropertyAccess::has($cache, $name)) continue; |
|
| 721 | 721 | |
| 722 | 722 | TPropertyAccess::set($cache, $name, $value); |
| 723 | 723 | } |
| 724 | 724 | |
| 725 | - $this->loadFlushInterval($cacheModel,$node); |
|
| 725 | + $this->loadFlushInterval($cacheModel, $node); |
|
| 726 | 726 | |
| 727 | 727 | $cacheModel->initialize($cache); |
| 728 | 728 | $this->_manager->addCacheModel($cacheModel); |
| 729 | 729 | foreach($node->xpath('flushOnExecute') as $flush) |
| 730 | - $this->loadFlushOnCache($cacheModel,$node,$flush); |
|
| 730 | + $this->loadFlushOnCache($cacheModel, $node, $flush); |
|
| 731 | 731 | } |
| 732 | 732 | |
| 733 | 733 | /** |
@@ -737,27 +737,27 @@ discard block |
||
| 737 | 737 | */ |
| 738 | 738 | protected function loadFlushInterval($cacheModel, $node) |
| 739 | 739 | { |
| 740 | - $flushInterval = $node->xpath('flushInterval'); |
|
| 741 | - if($flushInterval === null || count($flushInterval) === 0) return; |
|
| 742 | - $duration = 0; |
|
| 740 | + $flushInterval=$node->xpath('flushInterval'); |
|
| 741 | + if($flushInterval===null || count($flushInterval)===0) return; |
|
| 742 | + $duration=0; |
|
| 743 | 743 | foreach($flushInterval[0]->attributes() as $name=>$value) |
| 744 | 744 | { |
| 745 | 745 | switch(strToLower($name)) |
| 746 | 746 | { |
| 747 | 747 | case 'seconds': |
| 748 | - $duration += (integer)$value; |
|
| 748 | + $duration+=(integer) $value; |
|
| 749 | 749 | break; |
| 750 | 750 | case 'minutes': |
| 751 | - $duration += 60 * (integer)$value; |
|
| 751 | + $duration+=60 * (integer) $value; |
|
| 752 | 752 | break; |
| 753 | 753 | case 'hours': |
| 754 | - $duration += 3600 * (integer)$value; |
|
| 754 | + $duration+=3600 * (integer) $value; |
|
| 755 | 755 | break; |
| 756 | 756 | case 'days': |
| 757 | - $duration += 86400 * (integer)$value; |
|
| 757 | + $duration+=86400 * (integer) $value; |
|
| 758 | 758 | break; |
| 759 | 759 | case 'duration': |
| 760 | - $duration = (integer)$value; |
|
| 760 | + $duration=(integer) $value; |
|
| 761 | 761 | break 2; // switch, foreach |
| 762 | 762 | } |
| 763 | 763 | } |
@@ -770,15 +770,15 @@ discard block |
||
| 770 | 770 | * @param SimpleXmlElement parent node. |
| 771 | 771 | * @param SimpleXmlElement flush node. |
| 772 | 772 | */ |
| 773 | - protected function loadFlushOnCache($cacheModel,$parent,$node) |
|
| 773 | + protected function loadFlushOnCache($cacheModel, $parent, $node) |
|
| 774 | 774 | { |
| 775 | - $id = $cacheModel->getID(); |
|
| 775 | + $id=$cacheModel->getID(); |
|
| 776 | 776 | if(!isset($this->_FlushOnExecuteStatements[$id])) |
| 777 | - $this->_FlushOnExecuteStatements[$id] = array(); |
|
| 777 | + $this->_FlushOnExecuteStatements[$id]=array(); |
|
| 778 | 778 | foreach($node->attributes() as $name=>$value) |
| 779 | 779 | { |
| 780 | 780 | if(strtolower($name)==='statement') |
| 781 | - $this->_FlushOnExecuteStatements[$id][] = (string)$value; |
|
| 781 | + $this->_FlushOnExecuteStatements[$id][]=(string) $value; |
|
| 782 | 782 | } |
| 783 | 783 | } |
| 784 | 784 | |
@@ -789,10 +789,10 @@ discard block |
||
| 789 | 789 | { |
| 790 | 790 | foreach($this->_FlushOnExecuteStatements as $cacheID => $statementIDs) |
| 791 | 791 | { |
| 792 | - $cacheModel = $this->_manager->getCacheModel($cacheID); |
|
| 792 | + $cacheModel=$this->_manager->getCacheModel($cacheID); |
|
| 793 | 793 | foreach($statementIDs as $statementID) |
| 794 | 794 | { |
| 795 | - $statement = $this->_manager->getMappedStatement($statementID); |
|
| 795 | + $statement=$this->_manager->getMappedStatement($statementID); |
|
| 796 | 796 | $cacheModel->registerTriggerStatement($statement); |
| 797 | 797 | } |
| 798 | 798 | } |
@@ -116,6 +116,7 @@ |
||
| 116 | 116 | /** |
| 117 | 117 | * @param object handler to method calls. |
| 118 | 118 | * @param object the object to by proxied. |
| 119 | + * @param TLazyLoadList $handler |
|
| 119 | 120 | */ |
| 120 | 121 | public function __construct($handler, $object) |
| 121 | 122 | { |
@@ -36,11 +36,11 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | protected function __construct($mappedStatement, $param, $target, $propertyName) |
| 38 | 38 | { |
| 39 | - $this->_param = $param; |
|
| 40 | - $this->_target = $target; |
|
| 41 | - $this->_statement = $mappedStatement; |
|
| 39 | + $this->_param=$param; |
|
| 40 | + $this->_target=$target; |
|
| 41 | + $this->_statement=$mappedStatement; |
|
| 42 | 42 | $this->_connection=$mappedStatement->getManager()->getDbConnection(); |
| 43 | - $this->_propertyName = $propertyName; |
|
| 43 | + $this->_propertyName=$propertyName; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -53,12 +53,12 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public static function newInstance($mappedStatement, $param, $target, $propertyName) |
| 55 | 55 | { |
| 56 | - $handler = new self($mappedStatement, $param, $target, $propertyName); |
|
| 57 | - $statement = $mappedStatement->getStatement(); |
|
| 56 | + $handler=new self($mappedStatement, $param, $target, $propertyName); |
|
| 57 | + $statement=$mappedStatement->getStatement(); |
|
| 58 | 58 | $registry=$mappedStatement->getManager()->getTypeHandlers(); |
| 59 | - $list = $statement->createInstanceOfListClass($registry); |
|
| 59 | + $list=$statement->createInstanceOfListClass($registry); |
|
| 60 | 60 | if(!is_object($list)) |
| 61 | - throw new TSqlMapExecutionException('sqlmap_invalid_lazyload_list',$statement->getID()); |
|
| 61 | + throw new TSqlMapExecutionException('sqlmap_invalid_lazyload_list', $statement->getID()); |
|
| 62 | 62 | return new TObjectProxy($handler, $list); |
| 63 | 63 | } |
| 64 | 64 | |
@@ -77,10 +77,10 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | protected function fetchListData() |
| 79 | 79 | { |
| 80 | - if($this->_loaded == false) |
|
| 80 | + if($this->_loaded==false) |
|
| 81 | 81 | { |
| 82 | - $this->_innerList = $this->_statement->executeQueryForList($this->_connection,$this->_param); |
|
| 83 | - $this->_loaded = true; |
|
| 82 | + $this->_innerList=$this->_statement->executeQueryForList($this->_connection, $this->_param); |
|
| 83 | + $this->_loaded=true; |
|
| 84 | 84 | //replace the target property with real list |
| 85 | 85 | TPropertyAccess::set($this->_target, $this->_propertyName, $this->_innerList); |
| 86 | 86 | } |
@@ -119,8 +119,8 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | public function __construct($handler, $object) |
| 121 | 121 | { |
| 122 | - $this->_handler = $handler; |
|
| 123 | - $this->_object = $object; |
|
| 122 | + $this->_handler=$handler; |
|
| 123 | + $this->_object=$object; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * @param array method arguments |
| 131 | 131 | * @return mixed method return value. |
| 132 | 132 | */ |
| 133 | - public function __call($method,$params) |
|
| 133 | + public function __call($method, $params) |
|
| 134 | 134 | { |
| 135 | 135 | if($this->_handler->hasMethod($method)) |
| 136 | 136 | return $this->_handler->intercept($method, $params); |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * TLazyLoadList, TObjectProxy classes file. |
|
| 4 | - * |
|
| 5 | - * @author Wei Zhuo <weizhuo[at]gmail[dot]com> |
|
| 6 | - * @link https://github.com/pradosoft/prado |
|
| 7 | - * @copyright Copyright © 2005-2016 The PRADO Group |
|
| 8 | - * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
| 9 | - * @package System.Data.SqlMap |
|
| 10 | - */ |
|
| 3 | + * TLazyLoadList, TObjectProxy classes file. |
|
| 4 | + * |
|
| 5 | + * @author Wei Zhuo <weizhuo[at]gmail[dot]com> |
|
| 6 | + * @link https://github.com/pradosoft/prado |
|
| 7 | + * @copyright Copyright © 2005-2016 The PRADO Group |
|
| 8 | + * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
| 9 | + * @package System.Data.SqlMap |
|
| 10 | + */ |
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * TLazyLoadList executes mapped statements when the proxy collection is first accessed. |
@@ -40,6 +40,7 @@ discard block |
||
| 40 | 40 | * @param int page size |
| 41 | 41 | * @param mixed delegate for each data row retrieved. |
| 42 | 42 | * @param int number of page to fetch on initialization |
| 43 | + * @param integer $pageSize |
|
| 43 | 44 | */ |
| 44 | 45 | public function __construct(IMappedStatement $statement,$parameter, $pageSize, $delegate=null, $page=0) |
| 45 | 46 | { |
@@ -55,6 +56,8 @@ discard block |
||
| 55 | 56 | * @param mixed query parameters |
| 56 | 57 | * @param int page size. |
| 57 | 58 | * @param int number of page. |
| 59 | + * @param IMappedStatement $statement |
|
| 60 | + * @param integer $page |
|
| 58 | 61 | */ |
| 59 | 62 | protected function initialize($statement, $parameter, $pageSize, $page) |
| 60 | 63 | { |
@@ -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 | /** |