@@ -97,6 +97,10 @@ |
||
| 97 | 97 | return $cacheKey->getHash(); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | + /** |
|
| 101 | + * @param integer $skip |
|
| 102 | + * @param integer $max |
|
| 103 | + */ |
|
| 100 | 104 | protected function createCommand($connection, $parameter, $skip=null, $max=null) |
| 101 | 105 | { |
| 102 | 106 | return $this->_mappedStatement->getCommand()->create($this->getManager(), |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | public function __construct(TMappedStatement $statement) |
| 24 | 24 | { |
| 25 | - $this->_mappedStatement = $statement; |
|
| 25 | + $this->_mappedStatement=$statement; |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | public function getID() |
@@ -40,15 +40,15 @@ discard block |
||
| 40 | 40 | return $this->_mappedStatement->getManager(); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - public function executeQueryForMap($connection, $parameter,$keyProperty, $valueProperty=null, $skip=-1, $max=-1,$delegate=null) |
|
| 43 | + public function executeQueryForMap($connection, $parameter, $keyProperty, $valueProperty=null, $skip=-1, $max=-1, $delegate=null) |
|
| 44 | 44 | { |
| 45 | - $sql = $this->createCommand($connection, $parameter, $skip, $max); |
|
| 46 | - $key = $this->getCacheKey(array(clone($sql), $keyProperty, $valueProperty,$skip, $max)); |
|
| 47 | - $map = $this->getStatement()->getCache()->get($key); |
|
| 45 | + $sql=$this->createCommand($connection, $parameter, $skip, $max); |
|
| 46 | + $key=$this->getCacheKey(array(clone($sql), $keyProperty, $valueProperty, $skip, $max)); |
|
| 47 | + $map=$this->getStatement()->getCache()->get($key); |
|
| 48 | 48 | if($map===null) |
| 49 | 49 | { |
| 50 | - $map = $this->_mappedStatement->runQueryForMap( |
|
| 51 | - $connection, $parameter, $sql, $keyProperty, $valueProperty, $delegate); |
|
| 50 | + $map=$this->_mappedStatement->runQueryForMap( |
|
| 51 | + $connection, $parameter, $sql, $keyProperty, $valueProperty, $delegate); |
|
| 52 | 52 | $this->getStatement()->getCache()->set($key, $map); |
| 53 | 53 | } |
| 54 | 54 | return $map; |
@@ -66,12 +66,12 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | public function executeQueryForList($connection, $parameter, $result=null, $skip=-1, $max=-1, $delegate=null) |
| 68 | 68 | { |
| 69 | - $sql = $this->createCommand($connection, $parameter, $skip, $max); |
|
| 70 | - $key = $this->getCacheKey(array(clone($sql), $parameter, $skip, $max)); |
|
| 71 | - $list = $this->getStatement()->getCache()->get($key); |
|
| 69 | + $sql=$this->createCommand($connection, $parameter, $skip, $max); |
|
| 70 | + $key=$this->getCacheKey(array(clone($sql), $parameter, $skip, $max)); |
|
| 71 | + $list=$this->getStatement()->getCache()->get($key); |
|
| 72 | 72 | if($list===null) |
| 73 | 73 | { |
| 74 | - $list = $this->_mappedStatement->runQueryForList( |
|
| 74 | + $list=$this->_mappedStatement->runQueryForList( |
|
| 75 | 75 | $connection, $parameter, $sql, $result, $delegate); |
| 76 | 76 | $this->getStatement()->getCache()->set($key, $list); |
| 77 | 77 | } |
@@ -80,12 +80,12 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | public function executeQueryForObject($connection, $parameter, $result=null) |
| 82 | 82 | { |
| 83 | - $sql = $this->createCommand($connection, $parameter); |
|
| 84 | - $key = $this->getCacheKey(array(clone($sql), $parameter)); |
|
| 85 | - $object = $this->getStatement()->getCache()->get($key); |
|
| 83 | + $sql=$this->createCommand($connection, $parameter); |
|
| 84 | + $key=$this->getCacheKey(array(clone($sql), $parameter)); |
|
| 85 | + $object=$this->getStatement()->getCache()->get($key); |
|
| 86 | 86 | if($object===null) |
| 87 | 87 | { |
| 88 | - $object = $this->_mappedStatement->runQueryForObject($connection, $sql, $result); |
|
| 88 | + $object=$this->_mappedStatement->runQueryForObject($connection, $sql, $result); |
|
| 89 | 89 | $this->getStatement()->getCache()->set($key, $object); |
| 90 | 90 | } |
| 91 | 91 | return $object; |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | protected function getCacheKey($object) |
| 95 | 95 | { |
| 96 | - $cacheKey = new TSqlMapCacheKey($object); |
|
| 96 | + $cacheKey=new TSqlMapCacheKey($object); |
|
| 97 | 97 | return $cacheKey->getHash(); |
| 98 | 98 | } |
| 99 | 99 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | - * @return TSqlMapper The SqlMap used by this MappedStatement |
|
| 87 | + * @return TSqlMapManager The SqlMap used by this MappedStatement |
|
| 88 | 88 | */ |
| 89 | 89 | public function getManager() |
| 90 | 90 | { |
@@ -469,6 +469,7 @@ discard block |
||
| 469 | 469 | * @param IDbConnection database connection |
| 470 | 470 | * @param mixed insert statement parameter |
| 471 | 471 | * @param TSqlMapSelectKey select key statement |
| 472 | + * @param TSqlMapSelectKey $selectKey |
|
| 472 | 473 | * @return string last insert ID. |
| 473 | 474 | */ |
| 474 | 475 | protected function executeSelectKey($connection, $parameter, $selectKey) |
@@ -569,6 +570,7 @@ discard block |
||
| 569 | 570 | * @param string result object class name |
| 570 | 571 | * @param array a result set row retrieved from the database |
| 571 | 572 | * @param object the result object, will create if necessary. |
| 573 | + * @param string $resultClass |
|
| 572 | 574 | * @return object result object filled with data |
| 573 | 575 | */ |
| 574 | 576 | protected function fillResultClass($resultClass, $row, $resultObject) |
@@ -591,6 +593,7 @@ discard block |
||
| 591 | 593 | * Apply the result to a TList or an array. |
| 592 | 594 | * @param array a result set row retrieved from the database |
| 593 | 595 | * @param object result object, array or list |
| 596 | + * @param ArrayAccess $resultObject |
|
| 594 | 597 | * @return object result filled with data. |
| 595 | 598 | */ |
| 596 | 599 | protected function fillResultArrayList($row, $resultObject) |
@@ -633,6 +636,7 @@ discard block |
||
| 633 | 636 | * @param string result map name. |
| 634 | 637 | * @param array a result set row retrieved from the database |
| 635 | 638 | * @param object result object to fill, will create new instances if required. |
| 639 | + * @param string $parentGroup |
|
| 636 | 640 | * @return object result object filled with data. |
| 637 | 641 | */ |
| 638 | 642 | protected function fillResultMap($resultMapName, $row, $parentGroup=null, &$resultObject=null) |
@@ -772,6 +776,7 @@ discard block |
||
| 772 | 776 | * Converts the first array value to scalar value of given type. |
| 773 | 777 | * @param array list of results |
| 774 | 778 | * @param string scalar type. |
| 779 | + * @param string $type |
|
| 775 | 780 | * @return mixed scalar value. |
| 776 | 781 | */ |
| 777 | 782 | protected function getScalarResult($result, $type) |
@@ -961,6 +966,10 @@ discard block |
||
| 961 | 966 | public function setKeys($value){ $this->_keys = $value; } |
| 962 | 967 | |
| 963 | 968 | public function getMethod(){ return $this->_method; } |
| 969 | + |
|
| 970 | + /** |
|
| 971 | + * @param integer $value |
|
| 972 | + */ |
|
| 964 | 973 | public function setMethod($value){ $this->_method = $value; } |
| 965 | 974 | } |
| 966 | 975 | |
@@ -1003,6 +1012,7 @@ discard block |
||
| 1003 | 1012 | * @param string parent node id |
| 1004 | 1013 | * @param string new node id |
| 1005 | 1014 | * @param mixed node value |
| 1015 | + * @param string $node |
|
| 1006 | 1016 | */ |
| 1007 | 1017 | public function add($parent, $node, $object='') |
| 1008 | 1018 | { |
@@ -1168,6 +1178,9 @@ discard block |
||
| 1168 | 1178 | private $_parameterObject; |
| 1169 | 1179 | private $_list; |
| 1170 | 1180 | |
| 1181 | + /** |
|
| 1182 | + * @param ArrayAccess $list |
|
| 1183 | + */ |
|
| 1171 | 1184 | public function __construct($result, $parameter, &$list) |
| 1172 | 1185 | { |
| 1173 | 1186 | $this->_resultObject = $result; |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | /** |
| 45 | 45 | * @var boolean true when data is mapped to a particular row. |
| 46 | 46 | */ |
| 47 | - private $_IsRowDataFound = false; |
|
| 47 | + private $_IsRowDataFound=false; |
|
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * @var TSQLMapObjectCollectionTree group by object collection tree |
@@ -54,17 +54,17 @@ discard block |
||
| 54 | 54 | /** |
| 55 | 55 | * @var Post select is to query for list. |
| 56 | 56 | */ |
| 57 | - const QUERY_FOR_LIST = 0; |
|
| 57 | + const QUERY_FOR_LIST=0; |
|
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | 60 | * @var Post select is to query for list. |
| 61 | 61 | */ |
| 62 | - const QUERY_FOR_ARRAY = 1; |
|
| 62 | + const QUERY_FOR_ARRAY=1; |
|
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * @var Post select is to query for object. |
| 66 | 66 | */ |
| 67 | - const QUERY_FOR_OBJECT = 2; |
|
| 67 | + const QUERY_FOR_OBJECT=2; |
|
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | 70 | * @return string Name used to identify the TMappedStatement amongst the others. |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | protected function initialGroupByResults() |
| 106 | 106 | { |
| 107 | - $this->_groupBy = new TSqlMapObjectCollectionTree(); |
|
| 107 | + $this->_groupBy=new TSqlMapObjectCollectionTree(); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | public function __construct(TSqlMapManager $sqlMap, TSqlMapStatement $statement) |
| 116 | 116 | { |
| 117 | - $this->_manager = $sqlMap; |
|
| 118 | - $this->_statement = $statement; |
|
| 119 | - $this->_command = new TPreparedCommand(); |
|
| 117 | + $this->_manager=$sqlMap; |
|
| 118 | + $this->_statement=$statement; |
|
| 119 | + $this->_command=new TPreparedCommand(); |
|
| 120 | 120 | $this->initialGroupByResults(); |
| 121 | 121 | } |
| 122 | 122 | |
@@ -161,10 +161,10 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | protected function executeSQLQueryLimit($connection, $command, $max, $skip) |
| 163 | 163 | { |
| 164 | - if($max>-1 || $skip > -1) |
|
| 164 | + if($max > -1 || $skip > -1) |
|
| 165 | 165 | { |
| 166 | - $maxStr=$max>0?' LIMIT '.$max:''; |
|
| 167 | - $skipStr=$skip>0?' OFFSET '.$skip:''; |
|
| 166 | + $maxStr=$max > 0 ? ' LIMIT '.$max : ''; |
|
| 167 | + $skipStr=$skip > 0 ? ' OFFSET '.$skip : ''; |
|
| 168 | 168 | $command->setText($command->getText().$maxStr.$skipStr); |
| 169 | 169 | } |
| 170 | 170 | $connection->setActive(true); |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | */ |
| 202 | 202 | public function executeQueryForList($connection, $parameter, $result=null, $skip=-1, $max=-1, $delegate=null) |
| 203 | 203 | { |
| 204 | - $sql = $this->_command->create($this->_manager, $connection, $this->_statement, $parameter,$skip,$max); |
|
| 204 | + $sql=$this->_command->create($this->_manager, $connection, $this->_statement, $parameter, $skip, $max); |
|
| 205 | 205 | return $this->runQueryForList($connection, $parameter, $sql, $result, $delegate); |
| 206 | 206 | } |
| 207 | 207 | |
@@ -224,17 +224,16 @@ discard block |
||
| 224 | 224 | public function runQueryForList($connection, $parameter, $sql, $result, $delegate=null) |
| 225 | 225 | { |
| 226 | 226 | $registry=$this->getManager()->getTypeHandlers(); |
| 227 | - $list = $result instanceof ArrayAccess ? $result : |
|
| 228 | - $this->_statement->createInstanceOfListClass($registry); |
|
| 227 | + $list=$result instanceof ArrayAccess ? $result : $this->_statement->createInstanceOfListClass($registry); |
|
| 229 | 228 | $connection->setActive(true); |
| 230 | - $reader = $sql->query(); |
|
| 229 | + $reader=$sql->query(); |
|
| 231 | 230 | //$reader = $this->executeSQLQueryLimit($connection, $sql, $max, $skip); |
| 232 | 231 | if($delegate!==null) |
| 233 | 232 | { |
| 234 | 233 | foreach($reader as $row) |
| 235 | 234 | { |
| 236 | - $obj = $this->applyResultMap($row); |
|
| 237 | - $param = new TResultSetListItemParameter($obj, $parameter, $list); |
|
| 235 | + $obj=$this->applyResultMap($row); |
|
| 236 | + $param=new TResultSetListItemParameter($obj, $parameter, $list); |
|
| 238 | 237 | $this->raiseRowDelegate($delegate, $param); |
| 239 | 238 | } |
| 240 | 239 | } |
@@ -244,13 +243,13 @@ discard block |
||
| 244 | 243 | foreach($reader as $row) |
| 245 | 244 | { |
| 246 | 245 | // var_dump($row); |
| 247 | - $list[] = $this->applyResultMap($row); |
|
| 246 | + $list[]=$this->applyResultMap($row); |
|
| 248 | 247 | } |
| 249 | 248 | } |
| 250 | 249 | |
| 251 | 250 | if(!$this->_groupBy->isEmpty()) |
| 252 | 251 | { |
| 253 | - $list = $this->_groupBy->collect(); |
|
| 252 | + $list=$this->_groupBy->collect(); |
|
| 254 | 253 | $this->initialGroupByResults(); |
| 255 | 254 | } |
| 256 | 255 | |
@@ -272,9 +271,9 @@ discard block |
||
| 272 | 271 | * @param callback row delegate handler |
| 273 | 272 | * @return array An array of object containing the rows keyed by keyProperty. |
| 274 | 273 | */ |
| 275 | - public function executeQueryForMap($connection, $parameter, $keyProperty, $valueProperty=null, $skip=-1, $max=-1, $delegate=null) |
|
| 274 | + public function executeQueryForMap($connection, $parameter, $keyProperty, $valueProperty=null, $skip=-1, $max=-1, $delegate=null) |
|
| 276 | 275 | { |
| 277 | - $sql = $this->_command->create($this->_manager, $connection, $this->_statement, $parameter, $skip, $max); |
|
| 276 | + $sql=$this->_command->create($this->_manager, $connection, $this->_statement, $parameter, $skip, $max); |
|
| 278 | 277 | return $this->runQueryForMap($connection, $parameter, $sql, $keyProperty, $valueProperty, $delegate); |
| 279 | 278 | } |
| 280 | 279 | |
@@ -298,20 +297,19 @@ discard block |
||
| 298 | 297 | */ |
| 299 | 298 | public function runQueryForMap($connection, $parameter, $command, $keyProperty, $valueProperty=null, $delegate=null) |
| 300 | 299 | { |
| 301 | - $map = array(); |
|
| 300 | + $map=array(); |
|
| 302 | 301 | //$recordSet = $this->executeSQLQuery($connection, $sql); |
| 303 | 302 | $connection->setActive(true); |
| 304 | - $reader = $command->query(); |
|
| 303 | + $reader=$command->query(); |
|
| 305 | 304 | if($delegate!==null) |
| 306 | 305 | { |
| 307 | 306 | //while($row = $recordSet->fetchRow()) |
| 308 | 307 | foreach($reader as $row) |
| 309 | 308 | { |
| 310 | - $obj = $this->applyResultMap($row); |
|
| 311 | - $key = TPropertyAccess::get($obj, $keyProperty); |
|
| 312 | - $value = ($valueProperty===null) ? $obj : |
|
| 313 | - TPropertyAccess::get($obj, $valueProperty); |
|
| 314 | - $param = new TResultSetMapItemParameter($key, $value, $parameter, $map); |
|
| 309 | + $obj=$this->applyResultMap($row); |
|
| 310 | + $key=TPropertyAccess::get($obj, $keyProperty); |
|
| 311 | + $value=($valueProperty===null) ? $obj : TPropertyAccess::get($obj, $valueProperty); |
|
| 312 | + $param=new TResultSetMapItemParameter($key, $value, $parameter, $map); |
|
| 315 | 313 | $this->raiseRowDelegate($delegate, $param); |
| 316 | 314 | } |
| 317 | 315 | } |
@@ -320,10 +318,9 @@ discard block |
||
| 320 | 318 | //while($row = $recordSet->fetchRow()) |
| 321 | 319 | foreach($reader as $row) |
| 322 | 320 | { |
| 323 | - $obj = $this->applyResultMap($row); |
|
| 324 | - $key = TPropertyAccess::get($obj, $keyProperty); |
|
| 325 | - $map[$key] = ($valueProperty===null) ? $obj : |
|
| 326 | - TPropertyAccess::get($obj, $valueProperty); |
|
| 321 | + $obj=$this->applyResultMap($row); |
|
| 322 | + $key=TPropertyAccess::get($obj, $keyProperty); |
|
| 323 | + $map[$key]=($valueProperty===null) ? $obj : TPropertyAccess::get($obj, $valueProperty); |
|
| 327 | 324 | } |
| 328 | 325 | } |
| 329 | 326 | $this->onExecuteQuery($command); |
@@ -340,22 +337,22 @@ discard block |
||
| 340 | 337 | { |
| 341 | 338 | if(is_string($handler)) |
| 342 | 339 | { |
| 343 | - call_user_func($handler,$this,$param); |
|
| 340 | + call_user_func($handler, $this, $param); |
|
| 344 | 341 | } |
| 345 | - else if(is_callable($handler,true)) |
|
| 342 | + else if(is_callable($handler, true)) |
|
| 346 | 343 | { |
| 347 | 344 | // an array: 0 - object, 1 - method name/path |
| 348 | - list($object,$method)=$handler; |
|
| 345 | + list($object, $method)=$handler; |
|
| 349 | 346 | if(is_string($object)) // static method call |
| 350 | - call_user_func($handler,$this,$param); |
|
| 347 | + call_user_func($handler, $this, $param); |
|
| 351 | 348 | else |
| 352 | 349 | { |
| 353 | - if(($pos=strrpos($method,'.'))!==false) |
|
| 350 | + if(($pos=strrpos($method, '.'))!==false) |
|
| 354 | 351 | { |
| 355 | - $object=$this->getSubProperty(substr($method,0,$pos)); |
|
| 356 | - $method=substr($method,$pos+1); |
|
| 352 | + $object=$this->getSubProperty(substr($method, 0, $pos)); |
|
| 353 | + $method=substr($method, $pos + 1); |
|
| 357 | 354 | } |
| 358 | - $object->$method($this,$param); |
|
| 355 | + $object->$method($this, $param); |
|
| 359 | 356 | } |
| 360 | 357 | } |
| 361 | 358 | else |
@@ -372,7 +369,7 @@ discard block |
||
| 372 | 369 | */ |
| 373 | 370 | public function executeQueryForObject($connection, $parameter, $result=null) |
| 374 | 371 | { |
| 375 | - $sql = $this->_command->create($this->_manager, $connection, $this->_statement, $parameter); |
|
| 372 | + $sql=$this->_command->create($this->_manager, $connection, $this->_statement, $parameter); |
|
| 376 | 373 | return $this->runQueryForObject($connection, $sql, $result); |
| 377 | 374 | } |
| 378 | 375 | |
@@ -391,16 +388,16 @@ discard block |
||
| 391 | 388 | */ |
| 392 | 389 | public function runQueryForObject($connection, $command, &$result) |
| 393 | 390 | { |
| 394 | - $object = null; |
|
| 391 | + $object=null; |
|
| 395 | 392 | $connection->setActive(true); |
| 396 | 393 | foreach($command->query() as $row) |
| 397 | - $object = $this->applyResultMap($row, $result); |
|
| 394 | + $object=$this->applyResultMap($row, $result); |
|
| 398 | 395 | |
| 399 | 396 | if(!$this->_groupBy->isEmpty()) |
| 400 | 397 | { |
| 401 | - $list = $this->_groupBy->collect(); |
|
| 398 | + $list=$this->_groupBy->collect(); |
|
| 402 | 399 | $this->initialGroupByResults(); |
| 403 | - $object = $list[0]; |
|
| 400 | + $object=$list[0]; |
|
| 404 | 401 | } |
| 405 | 402 | |
| 406 | 403 | $this->executePostSelect($connection); |
@@ -418,14 +415,14 @@ discard block |
||
| 418 | 415 | */ |
| 419 | 416 | public function executeInsert($connection, $parameter) |
| 420 | 417 | { |
| 421 | - $generatedKey = $this->getPreGeneratedSelectKey($connection, $parameter); |
|
| 418 | + $generatedKey=$this->getPreGeneratedSelectKey($connection, $parameter); |
|
| 422 | 419 | |
| 423 | - $command = $this->_command->create($this->_manager, $connection, $this->_statement, $parameter); |
|
| 420 | + $command=$this->_command->create($this->_manager, $connection, $this->_statement, $parameter); |
|
| 424 | 421 | // var_dump($command,$parameter); |
| 425 | - $result = $command->execute(); |
|
| 422 | + $result=$command->execute(); |
|
| 426 | 423 | |
| 427 | 424 | if($generatedKey===null) |
| 428 | - $generatedKey = $this->getPostGeneratedSelectKey($connection, $parameter); |
|
| 425 | + $generatedKey=$this->getPostGeneratedSelectKey($connection, $parameter); |
|
| 429 | 426 | |
| 430 | 427 | $this->executePostSelect($connection); |
| 431 | 428 | $this->onExecuteQuery($command); |
@@ -442,7 +439,7 @@ discard block |
||
| 442 | 439 | { |
| 443 | 440 | if($this->_statement instanceof TSqlMapInsert) |
| 444 | 441 | { |
| 445 | - $selectKey = $this->_statement->getSelectKey(); |
|
| 442 | + $selectKey=$this->_statement->getSelectKey(); |
|
| 446 | 443 | if(($selectKey!==null) && !$selectKey->getIsAfter()) |
| 447 | 444 | return $this->executeSelectKey($connection, $parameter, $selectKey); |
| 448 | 445 | } |
@@ -458,7 +455,7 @@ discard block |
||
| 458 | 455 | { |
| 459 | 456 | if($this->_statement instanceof TSqlMapInsert) |
| 460 | 457 | { |
| 461 | - $selectKey = $this->_statement->getSelectKey(); |
|
| 458 | + $selectKey=$this->_statement->getSelectKey(); |
|
| 462 | 459 | if(($selectKey!==null) && $selectKey->getIsAfter()) |
| 463 | 460 | return $this->executeSelectKey($connection, $parameter, $selectKey); |
| 464 | 461 | } |
@@ -473,10 +470,10 @@ discard block |
||
| 473 | 470 | */ |
| 474 | 471 | protected function executeSelectKey($connection, $parameter, $selectKey) |
| 475 | 472 | { |
| 476 | - $mappedStatement = $this->getManager()->getMappedStatement($selectKey->getID()); |
|
| 477 | - $generatedKey = $mappedStatement->executeQueryForObject( |
|
| 473 | + $mappedStatement=$this->getManager()->getMappedStatement($selectKey->getID()); |
|
| 474 | + $generatedKey=$mappedStatement->executeQueryForObject( |
|
| 478 | 475 | $connection, $parameter, null); |
| 479 | - if(strlen($prop = $selectKey->getProperty()) > 0) |
|
| 476 | + if(strlen($prop=$selectKey->getProperty()) > 0) |
|
| 480 | 477 | TPropertyAccess::set($parameter, $prop, $generatedKey); |
| 481 | 478 | return $generatedKey; |
| 482 | 479 | } |
@@ -490,8 +487,8 @@ discard block |
||
| 490 | 487 | */ |
| 491 | 488 | public function executeUpdate($connection, $parameter) |
| 492 | 489 | { |
| 493 | - $sql = $this->_command->create($this->getManager(),$connection, $this->_statement, $parameter); |
|
| 494 | - $affectedRows = $sql->execute(); |
|
| 490 | + $sql=$this->_command->create($this->getManager(), $connection, $this->_statement, $parameter); |
|
| 491 | + $affectedRows=$sql->execute(); |
|
| 495 | 492 | //$this->executeSQLQuery($connection, $sql); |
| 496 | 493 | $this->executePostSelect($connection); |
| 497 | 494 | $this->onExecuteQuery($sql); |
@@ -506,24 +503,24 @@ discard block |
||
| 506 | 503 | { |
| 507 | 504 | while(count($this->_selectQueue)) |
| 508 | 505 | { |
| 509 | - $postSelect = array_shift($this->_selectQueue); |
|
| 510 | - $method = $postSelect->getMethod(); |
|
| 511 | - $statement = $postSelect->getStatement(); |
|
| 512 | - $property = $postSelect->getResultProperty()->getProperty(); |
|
| 513 | - $keys = $postSelect->getKeys(); |
|
| 514 | - $resultObject = $postSelect->getResultObject(); |
|
| 515 | - |
|
| 516 | - if($method == self::QUERY_FOR_LIST || $method == self::QUERY_FOR_ARRAY) |
|
| 506 | + $postSelect=array_shift($this->_selectQueue); |
|
| 507 | + $method=$postSelect->getMethod(); |
|
| 508 | + $statement=$postSelect->getStatement(); |
|
| 509 | + $property=$postSelect->getResultProperty()->getProperty(); |
|
| 510 | + $keys=$postSelect->getKeys(); |
|
| 511 | + $resultObject=$postSelect->getResultObject(); |
|
| 512 | + |
|
| 513 | + if($method==self::QUERY_FOR_LIST || $method==self::QUERY_FOR_ARRAY) |
|
| 517 | 514 | { |
| 518 | - $values = $statement->executeQueryForList($connection, $keys, null); |
|
| 515 | + $values=$statement->executeQueryForList($connection, $keys, null); |
|
| 519 | 516 | |
| 520 | - if($method == self::QUERY_FOR_ARRAY) |
|
| 521 | - $values = $values->toArray(); |
|
| 517 | + if($method==self::QUERY_FOR_ARRAY) |
|
| 518 | + $values=$values->toArray(); |
|
| 522 | 519 | TPropertyAccess::set($resultObject, $property, $values); |
| 523 | 520 | } |
| 524 | - else if($method == self::QUERY_FOR_OBJECT) |
|
| 521 | + else if($method==self::QUERY_FOR_OBJECT) |
|
| 525 | 522 | { |
| 526 | - $value = $statement->executeQueryForObject($connection, $keys, null); |
|
| 523 | + $value=$statement->executeQueryForObject($connection, $keys, null); |
|
| 527 | 524 | TPropertyAccess::set($resultObject, $property, $value); |
| 528 | 525 | } |
| 529 | 526 | } |
@@ -546,21 +543,21 @@ discard block |
||
| 546 | 543 | */ |
| 547 | 544 | protected function applyResultMap($row, &$resultObject=null) |
| 548 | 545 | { |
| 549 | - if($row === false) return null; |
|
| 546 | + if($row===false) return null; |
|
| 550 | 547 | |
| 551 | - $resultMapName = $this->_statement->getResultMap(); |
|
| 552 | - $resultClass = $this->_statement->getResultClass(); |
|
| 548 | + $resultMapName=$this->_statement->getResultMap(); |
|
| 549 | + $resultClass=$this->_statement->getResultClass(); |
|
| 553 | 550 | |
| 554 | 551 | $obj=null; |
| 555 | 552 | if($this->getManager()->getResultMaps()->contains($resultMapName)) |
| 556 | - $obj = $this->fillResultMap($resultMapName, $row, null, $resultObject); |
|
| 553 | + $obj=$this->fillResultMap($resultMapName, $row, null, $resultObject); |
|
| 557 | 554 | else if(strlen($resultClass) > 0) |
| 558 | - $obj = $this->fillResultClass($resultClass, $row, $resultObject); |
|
| 555 | + $obj=$this->fillResultClass($resultClass, $row, $resultObject); |
|
| 559 | 556 | else |
| 560 | - $obj = $this->fillDefaultResultMap(null, $row, $resultObject); |
|
| 561 | - if(class_exists('TActiveRecord',false) && $obj instanceof TActiveRecord) |
|
| 557 | + $obj=$this->fillDefaultResultMap(null, $row, $resultObject); |
|
| 558 | + if(class_exists('TActiveRecord', false) && $obj instanceof TActiveRecord) |
|
| 562 | 559 | //Create a new clean active record. |
| 563 | - $obj=TActiveRecord::createRecord(get_class($obj),$obj); |
|
| 560 | + $obj=TActiveRecord::createRecord(get_class($obj), $obj); |
|
| 564 | 561 | return $obj; |
| 565 | 562 | } |
| 566 | 563 | |
@@ -575,8 +572,8 @@ discard block |
||
| 575 | 572 | { |
| 576 | 573 | if($resultObject===null) |
| 577 | 574 | { |
| 578 | - $registry = $this->getManager()->getTypeHandlers(); |
|
| 579 | - $resultObject = $this->_statement->createInstanceOfResultClass($registry,$row); |
|
| 575 | + $registry=$this->getManager()->getTypeHandlers(); |
|
| 576 | + $resultObject=$this->_statement->createInstanceOfResultClass($registry, $row); |
|
| 580 | 577 | } |
| 581 | 578 | |
| 582 | 579 | if($resultObject instanceOf ArrayAccess) |
@@ -597,10 +594,10 @@ discard block |
||
| 597 | 594 | { |
| 598 | 595 | if($resultObject instanceof TList) |
| 599 | 596 | foreach($row as $v) |
| 600 | - $resultObject[] = $v; |
|
| 597 | + $resultObject[]=$v; |
|
| 601 | 598 | else |
| 602 | 599 | foreach($row as $k => $v) |
| 603 | - $resultObject[$k] = $v; |
|
| 600 | + $resultObject[$k]=$v; |
|
| 604 | 601 | return $resultObject; |
| 605 | 602 | } |
| 606 | 603 | |
@@ -612,18 +609,18 @@ discard block |
||
| 612 | 609 | */ |
| 613 | 610 | protected function fillResultObjectProperty($row, $resultObject) |
| 614 | 611 | { |
| 615 | - $index = 0; |
|
| 612 | + $index=0; |
|
| 616 | 613 | $registry=$this->getManager()->getTypeHandlers(); |
| 617 | 614 | foreach($row as $k=>$v) |
| 618 | 615 | { |
| 619 | - $property = new TResultProperty; |
|
| 616 | + $property=new TResultProperty; |
|
| 620 | 617 | if(is_string($k) && strlen($k) > 0) |
| 621 | 618 | $property->setColumn($k); |
| 622 | 619 | $property->setColumnIndex(++$index); |
| 623 | - $type = gettype(TPropertyAccess::get($resultObject,$k)); |
|
| 620 | + $type=gettype(TPropertyAccess::get($resultObject, $k)); |
|
| 624 | 621 | $property->setType($type); |
| 625 | - $value = $property->getPropertyValue($registry,$row); |
|
| 626 | - TPropertyAccess::set($resultObject, $k,$value); |
|
| 622 | + $value=$property->getPropertyValue($registry, $row); |
|
| 623 | + TPropertyAccess::set($resultObject, $k, $value); |
|
| 627 | 624 | } |
| 628 | 625 | return $resultObject; |
| 629 | 626 | } |
@@ -637,12 +634,12 @@ discard block |
||
| 637 | 634 | */ |
| 638 | 635 | protected function fillResultMap($resultMapName, $row, $parentGroup=null, &$resultObject=null) |
| 639 | 636 | { |
| 640 | - $resultMap = $this->getManager()->getResultMap($resultMapName); |
|
| 641 | - $registry = $this->getManager()->getTypeHandlers(); |
|
| 642 | - $resultMap = $resultMap->resolveSubMap($registry,$row); |
|
| 637 | + $resultMap=$this->getManager()->getResultMap($resultMapName); |
|
| 638 | + $registry=$this->getManager()->getTypeHandlers(); |
|
| 639 | + $resultMap=$resultMap->resolveSubMap($registry, $row); |
|
| 643 | 640 | |
| 644 | 641 | if($resultObject===null) |
| 645 | - $resultObject = $resultMap->createInstanceOfResult($registry); |
|
| 642 | + $resultObject=$resultMap->createInstanceOfResult($registry); |
|
| 646 | 643 | |
| 647 | 644 | if(is_object($resultObject)) |
| 648 | 645 | { |
@@ -654,7 +651,7 @@ discard block |
||
| 654 | 651 | } |
| 655 | 652 | else |
| 656 | 653 | { |
| 657 | - $resultObject = $this->fillDefaultResultMap($resultMap, $row, $resultObject); |
|
| 654 | + $resultObject=$this->fillDefaultResultMap($resultMap, $row, $resultObject); |
|
| 658 | 655 | } |
| 659 | 656 | return $resultObject; |
| 660 | 657 | } |
@@ -669,11 +666,11 @@ discard block |
||
| 669 | 666 | */ |
| 670 | 667 | protected function addResultMapGroupBy($resultMap, $row, $parent, &$resultObject) |
| 671 | 668 | { |
| 672 | - $group = $this->getResultMapGroupKey($resultMap, $row); |
|
| 669 | + $group=$this->getResultMapGroupKey($resultMap, $row); |
|
| 673 | 670 | |
| 674 | 671 | if(empty($parent)) |
| 675 | 672 | { |
| 676 | - $rootObject = array('object'=>$resultObject, 'property' => null); |
|
| 673 | + $rootObject=array('object'=>$resultObject, 'property' => null); |
|
| 677 | 674 | $this->_groupBy->add(null, $group, $rootObject); |
| 678 | 675 | } |
| 679 | 676 | |
@@ -681,23 +678,23 @@ discard block |
||
| 681 | 678 | { |
| 682 | 679 | //set properties. |
| 683 | 680 | $this->setObjectProperty($resultMap, $property, $row, $resultObject); |
| 684 | - $nested = $property->getResultMapping(); |
|
| 681 | + $nested=$property->getResultMapping(); |
|
| 685 | 682 | |
| 686 | 683 | //nested property |
| 687 | 684 | if($this->getManager()->getResultMaps()->contains($nested)) |
| 688 | 685 | { |
| 689 | - $nestedMap = $this->getManager()->getResultMap($nested); |
|
| 690 | - $groupKey = $this->getResultMapGroupKey($nestedMap, $row); |
|
| 686 | + $nestedMap=$this->getManager()->getResultMap($nested); |
|
| 687 | + $groupKey=$this->getResultMapGroupKey($nestedMap, $row); |
|
| 691 | 688 | |
| 692 | 689 | //add the node reference first |
| 693 | 690 | if(empty($parent)) |
| 694 | 691 | $this->_groupBy->add($group, $groupKey, ''); |
| 695 | 692 | |
| 696 | 693 | //get the nested result mapping value |
| 697 | - $value = $this->fillResultMap($nested, $row, $groupKey); |
|
| 694 | + $value=$this->fillResultMap($nested, $row, $groupKey); |
|
| 698 | 695 | |
| 699 | 696 | //add it to the object tree graph |
| 700 | - $groupObject = array('object'=>$value, 'property' => $property->getProperty()); |
|
| 697 | + $groupObject=array('object'=>$value, 'property' => $property->getProperty()); |
|
| 701 | 698 | if(empty($parent)) |
| 702 | 699 | $this->_groupBy->add($group, $groupKey, $groupObject); |
| 703 | 700 | else |
@@ -715,7 +712,7 @@ discard block |
||
| 715 | 712 | */ |
| 716 | 713 | protected function getResultMapGroupKey($resultMap, $row) |
| 717 | 714 | { |
| 718 | - $groupBy = $resultMap->getGroupBy(); |
|
| 715 | + $groupBy=$resultMap->getGroupBy(); |
|
| 719 | 716 | if(isset($row[$groupBy])) |
| 720 | 717 | return $resultMap->getID().$row[$groupBy]; |
| 721 | 718 | else |
@@ -736,12 +733,12 @@ discard block |
||
| 736 | 733 | $resultObject=''; |
| 737 | 734 | |
| 738 | 735 | if($resultMap!==null) |
| 739 | - $result = $this->fillArrayResultMap($resultMap, $row, $resultObject); |
|
| 736 | + $result=$this->fillArrayResultMap($resultMap, $row, $resultObject); |
|
| 740 | 737 | else |
| 741 | - $result = $row; |
|
| 738 | + $result=$row; |
|
| 742 | 739 | |
| 743 | 740 | //if scalar result types |
| 744 | - if(count($result) == 1 && ($type = gettype($resultObject))!= 'array') |
|
| 741 | + if(count($result)==1 && ($type=gettype($resultObject))!='array') |
|
| 745 | 742 | return $this->getScalarResult($result, $type); |
| 746 | 743 | else |
| 747 | 744 | return $result; |
@@ -756,14 +753,14 @@ discard block |
||
| 756 | 753 | */ |
| 757 | 754 | protected function fillArrayResultMap($resultMap, $row, $resultObject) |
| 758 | 755 | { |
| 759 | - $result = array(); |
|
| 756 | + $result=array(); |
|
| 760 | 757 | $registry=$this->getManager()->getTypeHandlers(); |
| 761 | 758 | foreach($resultMap->getColumns() as $column) |
| 762 | 759 | { |
| 763 | 760 | if(($column->getType()===null) |
| 764 | 761 | && ($resultObject!==null) && !is_object($resultObject)) |
| 765 | 762 | $column->setType(gettype($resultObject)); |
| 766 | - $result[$column->getProperty()] = $column->getPropertyValue($registry,$row); |
|
| 763 | + $result[$column->getProperty()]=$column->getPropertyValue($registry, $row); |
|
| 767 | 764 | } |
| 768 | 765 | return $result; |
| 769 | 766 | } |
@@ -776,7 +773,7 @@ discard block |
||
| 776 | 773 | */ |
| 777 | 774 | protected function getScalarResult($result, $type) |
| 778 | 775 | { |
| 779 | - $scalar = array_shift($result); |
|
| 776 | + $scalar=array_shift($result); |
|
| 780 | 777 | settype($scalar, $type); |
| 781 | 778 | return $scalar; |
| 782 | 779 | } |
@@ -790,23 +787,23 @@ discard block |
||
| 790 | 787 | */ |
| 791 | 788 | protected function setObjectProperty($resultMap, $property, $row, &$resultObject) |
| 792 | 789 | { |
| 793 | - $select = $property->getSelect(); |
|
| 794 | - $key = $property->getProperty(); |
|
| 795 | - $nested = $property->getNestedResultMap(); |
|
| 790 | + $select=$property->getSelect(); |
|
| 791 | + $key=$property->getProperty(); |
|
| 792 | + $nested=$property->getNestedResultMap(); |
|
| 796 | 793 | $registry=$this->getManager()->getTypeHandlers(); |
| 797 | - if($key === '') |
|
| 794 | + if($key==='') |
|
| 798 | 795 | { |
| 799 | - $resultObject = $property->getPropertyValue($registry,$row); |
|
| 796 | + $resultObject=$property->getPropertyValue($registry, $row); |
|
| 800 | 797 | } |
| 801 | - else if(strlen($select) == 0 && ($nested===null)) |
|
| 798 | + else if(strlen($select)==0 && ($nested===null)) |
|
| 802 | 799 | { |
| 803 | - $value = $property->getPropertyValue($registry,$row); |
|
| 800 | + $value=$property->getPropertyValue($registry, $row); |
|
| 804 | 801 | |
| 805 | - $this->_IsRowDataFound = $this->_IsRowDataFound || ($value != null); |
|
| 802 | + $this->_IsRowDataFound=$this->_IsRowDataFound || ($value!=null); |
|
| 806 | 803 | if(is_array($resultObject) || is_object($resultObject)) |
| 807 | 804 | TPropertyAccess::set($resultObject, $key, $value); |
| 808 | 805 | else |
| 809 | - $resultObject = $value; |
|
| 806 | + $resultObject=$value; |
|
| 810 | 807 | } |
| 811 | 808 | else if($nested!==null) |
| 812 | 809 | { |
@@ -819,9 +816,9 @@ discard block |
||
| 819 | 816 | } |
| 820 | 817 | else |
| 821 | 818 | { |
| 822 | - $obj = $nested->createInstanceOfResult($this->getManager()->getTypeHandlers()); |
|
| 823 | - if($this->fillPropertyWithResultMap($nested, $row, $obj) == false) |
|
| 824 | - $obj = null; |
|
| 819 | + $obj=$nested->createInstanceOfResult($this->getManager()->getTypeHandlers()); |
|
| 820 | + if($this->fillPropertyWithResultMap($nested, $row, $obj)==false) |
|
| 821 | + $obj=null; |
|
| 825 | 822 | TPropertyAccess::set($resultObject, $key, $obj); |
| 826 | 823 | } |
| 827 | 824 | } |
@@ -841,9 +838,9 @@ discard block |
||
| 841 | 838 | */ |
| 842 | 839 | protected function enquequePostSelect($select, $resultMap, $property, $row, $resultObject) |
| 843 | 840 | { |
| 844 | - $statement = $this->getManager()->getMappedStatement($select); |
|
| 845 | - $key = $this->getPostSelectKeys($resultMap, $property, $row); |
|
| 846 | - $postSelect = new TPostSelectBinding; |
|
| 841 | + $statement=$this->getManager()->getMappedStatement($select); |
|
| 842 | + $key=$this->getPostSelectKeys($resultMap, $property, $row); |
|
| 843 | + $postSelect=new TPostSelectBinding; |
|
| 847 | 844 | $postSelect->setStatement($statement); |
| 848 | 845 | $postSelect->setResultObject($resultObject); |
| 849 | 846 | $postSelect->setResultProperty($property); |
@@ -851,10 +848,10 @@ discard block |
||
| 851 | 848 | |
| 852 | 849 | if($property->instanceOfListType($resultObject)) |
| 853 | 850 | { |
| 854 | - $values = null; |
|
| 851 | + $values=null; |
|
| 855 | 852 | if($property->getLazyLoad()) |
| 856 | 853 | { |
| 857 | - $values = TLazyLoadList::newInstance($statement, $key, |
|
| 854 | + $values=TLazyLoadList::newInstance($statement, $key, |
|
| 858 | 855 | $resultObject, $property->getProperty()); |
| 859 | 856 | TPropertyAccess::set($resultObject, $property->getProperty(), $values); |
| 860 | 857 | } |
@@ -867,7 +864,7 @@ discard block |
||
| 867 | 864 | $postSelect->setMethod(self::QUERY_FOR_OBJECT); |
| 868 | 865 | |
| 869 | 866 | if(!$property->getLazyLoad()) |
| 870 | - $this->_selectQueue[] = $postSelect; |
|
| 867 | + $this->_selectQueue[]=$postSelect; |
|
| 871 | 868 | } |
| 872 | 869 | |
| 873 | 870 | /** |
@@ -877,23 +874,23 @@ discard block |
||
| 877 | 874 | * @param array current row data. |
| 878 | 875 | * @return array list of primary key values. |
| 879 | 876 | */ |
| 880 | - protected function getPostSelectKeys($resultMap, $property,$row) |
|
| 877 | + protected function getPostSelectKeys($resultMap, $property, $row) |
|
| 881 | 878 | { |
| 882 | - $value = $property->getColumn(); |
|
| 883 | - if(is_int(strpos($value.',',0)) || is_int(strpos($value, '=',0))) |
|
| 879 | + $value=$property->getColumn(); |
|
| 880 | + if(is_int(strpos($value.',', 0)) || is_int(strpos($value, '=', 0))) |
|
| 884 | 881 | { |
| 885 | - $keys = array(); |
|
| 882 | + $keys=array(); |
|
| 886 | 883 | foreach(explode(',', $value) as $entry) |
| 887 | 884 | { |
| 888 | - $pair =explode('=',$entry); |
|
| 889 | - $keys[trim($pair[0])] = $row[trim($pair[1])]; |
|
| 885 | + $pair=explode('=', $entry); |
|
| 886 | + $keys[trim($pair[0])]=$row[trim($pair[1])]; |
|
| 890 | 887 | } |
| 891 | 888 | return $keys; |
| 892 | 889 | } |
| 893 | 890 | else |
| 894 | 891 | { |
| 895 | 892 | $registry=$this->getManager()->getTypeHandlers(); |
| 896 | - return $property->getPropertyValue($registry,$row); |
|
| 893 | + return $property->getPropertyValue($registry, $row); |
|
| 897 | 894 | } |
| 898 | 895 | } |
| 899 | 896 | |
@@ -906,30 +903,30 @@ discard block |
||
| 906 | 903 | */ |
| 907 | 904 | protected function fillPropertyWithResultMap($resultMap, $row, &$resultObject) |
| 908 | 905 | { |
| 909 | - $dataFound = false; |
|
| 906 | + $dataFound=false; |
|
| 910 | 907 | foreach($resultMap->getColumns() as $property) |
| 911 | 908 | { |
| 912 | - $this->_IsRowDataFound = false; |
|
| 909 | + $this->_IsRowDataFound=false; |
|
| 913 | 910 | $this->setObjectProperty($resultMap, $property, $row, $resultObject); |
| 914 | - $dataFound = $dataFound || $this->_IsRowDataFound; |
|
| 911 | + $dataFound=$dataFound || $this->_IsRowDataFound; |
|
| 915 | 912 | } |
| 916 | - $this->_IsRowDataFound = $dataFound; |
|
| 913 | + $this->_IsRowDataFound=$dataFound; |
|
| 917 | 914 | return $dataFound; |
| 918 | 915 | } |
| 919 | 916 | |
| 920 | 917 | public function __wakeup() |
| 921 | 918 | { |
| 922 | 919 | parent::__wakeup(); |
| 923 | - if (is_null($this->_selectQueue)) $this->_selectQueue = array(); |
|
| 920 | + if(is_null($this->_selectQueue)) $this->_selectQueue=array(); |
|
| 924 | 921 | } |
| 925 | 922 | |
| 926 | 923 | public function __sleep() |
| 927 | 924 | { |
| 928 | - $exprops = array(); $cn = __CLASS__; |
|
| 929 | - if (!count($this->_selectQueue)) $exprops[] = "\0$cn\0_selectQueue"; |
|
| 930 | - if (is_null($this->_groupBy)) $exprops[] = "\0$cn\0_groupBy"; |
|
| 931 | - if (!$this->_IsRowDataFound) $exprops[] = "\0$cn\0_IsRowDataFound"; |
|
| 932 | - return array_diff(parent::__sleep(),$exprops); |
|
| 925 | + $exprops=array(); $cn=__CLASS__; |
|
| 926 | + if(!count($this->_selectQueue)) $exprops[]="\0$cn\0_selectQueue"; |
|
| 927 | + if(is_null($this->_groupBy)) $exprops[]="\0$cn\0_groupBy"; |
|
| 928 | + if(!$this->_IsRowDataFound) $exprops[]="\0$cn\0_IsRowDataFound"; |
|
| 929 | + return array_diff(parent::__sleep(), $exprops); |
|
| 933 | 930 | } |
| 934 | 931 | } |
| 935 | 932 | |
@@ -948,20 +945,20 @@ discard block |
||
| 948 | 945 | private $_keys=null; |
| 949 | 946 | private $_method=TMappedStatement::QUERY_FOR_LIST; |
| 950 | 947 | |
| 951 | - public function getStatement(){ return $this->_statement; } |
|
| 952 | - public function setStatement($value){ $this->_statement = $value; } |
|
| 948 | + public function getStatement() { return $this->_statement; } |
|
| 949 | + public function setStatement($value) { $this->_statement=$value; } |
|
| 953 | 950 | |
| 954 | - public function getResultProperty(){ return $this->_property; } |
|
| 955 | - public function setResultProperty($value){ $this->_property = $value; } |
|
| 951 | + public function getResultProperty() { return $this->_property; } |
|
| 952 | + public function setResultProperty($value) { $this->_property=$value; } |
|
| 956 | 953 | |
| 957 | - public function getResultObject(){ return $this->_resultObject; } |
|
| 958 | - public function setResultObject($value){ $this->_resultObject = $value; } |
|
| 954 | + public function getResultObject() { return $this->_resultObject; } |
|
| 955 | + public function setResultObject($value) { $this->_resultObject=$value; } |
|
| 959 | 956 | |
| 960 | - public function getKeys(){ return $this->_keys; } |
|
| 961 | - public function setKeys($value){ $this->_keys = $value; } |
|
| 957 | + public function getKeys() { return $this->_keys; } |
|
| 958 | + public function setKeys($value) { $this->_keys=$value; } |
|
| 962 | 959 | |
| 963 | - public function getMethod(){ return $this->_method; } |
|
| 964 | - public function setMethod($value){ $this->_method = $value; } |
|
| 960 | + public function getMethod() { return $this->_method; } |
|
| 961 | + public function setMethod($value) { $this->_method=$value; } |
|
| 965 | 962 | } |
| 966 | 963 | |
| 967 | 964 | /** |
@@ -980,22 +977,22 @@ discard block |
||
| 980 | 977 | /** |
| 981 | 978 | * @var array object graph as tree |
| 982 | 979 | */ |
| 983 | - private $_tree = array(); |
|
| 980 | + private $_tree=array(); |
|
| 984 | 981 | /** |
| 985 | 982 | * @var array tree node values |
| 986 | 983 | */ |
| 987 | - private $_entries = array(); |
|
| 984 | + private $_entries=array(); |
|
| 988 | 985 | /** |
| 989 | 986 | * @var array resulting object collection |
| 990 | 987 | */ |
| 991 | - private $_list = array(); |
|
| 988 | + private $_list=array(); |
|
| 992 | 989 | |
| 993 | 990 | /** |
| 994 | 991 | * @return boolean true if the graph is empty |
| 995 | 992 | */ |
| 996 | 993 | public function isEmpty() |
| 997 | 994 | { |
| 998 | - return count($this->_entries) == 0; |
|
| 995 | + return count($this->_entries)==0; |
|
| 999 | 996 | } |
| 1000 | 997 | |
| 1001 | 998 | /** |
@@ -1009,22 +1006,22 @@ discard block |
||
| 1009 | 1006 | if(isset($this->_entries[$parent]) && ($this->_entries[$parent]!==null) |
| 1010 | 1007 | && isset($this->_entries[$node]) && ($this->_entries[$node]!==null)) |
| 1011 | 1008 | { |
| 1012 | - $this->_entries[$node] = $object; |
|
| 1009 | + $this->_entries[$node]=$object; |
|
| 1013 | 1010 | return; |
| 1014 | 1011 | } |
| 1015 | - $this->_entries[$node] = $object; |
|
| 1012 | + $this->_entries[$node]=$object; |
|
| 1016 | 1013 | if(empty($parent)) |
| 1017 | 1014 | { |
| 1018 | 1015 | if(isset($this->_entries[$node])) |
| 1019 | 1016 | return; |
| 1020 | - $this->_tree[$node] = array(); |
|
| 1017 | + $this->_tree[$node]=array(); |
|
| 1021 | 1018 | } |
| 1022 | - $found = $this->addNode($this->_tree, $parent, $node); |
|
| 1019 | + $found=$this->addNode($this->_tree, $parent, $node); |
|
| 1023 | 1020 | if(!$found && !empty($parent)) |
| 1024 | 1021 | { |
| 1025 | - $this->_tree[$parent] = array(); |
|
| 1026 | - if(!isset($this->_entries[$parent]) || $object !== '') |
|
| 1027 | - $this->_entries[$parent] = $object; |
|
| 1022 | + $this->_tree[$parent]=array(); |
|
| 1023 | + if(!isset($this->_entries[$parent]) || $object!=='') |
|
| 1024 | + $this->_entries[$parent]=$object; |
|
| 1028 | 1025 | $this->addNode($this->_tree, $parent, $node); |
| 1029 | 1026 | } |
| 1030 | 1027 | } |
@@ -1038,20 +1035,20 @@ discard block |
||
| 1038 | 1035 | */ |
| 1039 | 1036 | protected function addNode(&$childs, $parent, $node) |
| 1040 | 1037 | { |
| 1041 | - $found = false; |
|
| 1038 | + $found=false; |
|
| 1042 | 1039 | reset($childs); |
| 1043 | - for($i = 0, $k = count($childs); $i < $k; $i++) |
|
| 1040 | + for($i=0, $k=count($childs); $i < $k; $i++) |
|
| 1044 | 1041 | { |
| 1045 | - $key = key($childs); |
|
| 1042 | + $key=key($childs); |
|
| 1046 | 1043 | next($childs); |
| 1047 | - if($key == $parent) |
|
| 1044 | + if($key==$parent) |
|
| 1048 | 1045 | { |
| 1049 | - $found = true; |
|
| 1050 | - $childs[$key][$node] = array(); |
|
| 1046 | + $found=true; |
|
| 1047 | + $childs[$key][$node]=array(); |
|
| 1051 | 1048 | } |
| 1052 | 1049 | else |
| 1053 | 1050 | { |
| 1054 | - $found = $found || $this->addNode($childs[$key], $parent, $node); |
|
| 1051 | + $found=$found || $this->addNode($childs[$key], $parent, $node); |
|
| 1055 | 1052 | } |
| 1056 | 1053 | } |
| 1057 | 1054 | return $found; |
@@ -1073,9 +1070,9 @@ discard block |
||
| 1073 | 1070 | */ |
| 1074 | 1071 | protected function hasChildren(&$nodes) |
| 1075 | 1072 | { |
| 1076 | - $hasChildren = false; |
|
| 1073 | + $hasChildren=false; |
|
| 1077 | 1074 | foreach($nodes as $node) |
| 1078 | - if(count($node) != 0) |
|
| 1075 | + if(count($node)!=0) |
|
| 1079 | 1076 | return true; |
| 1080 | 1077 | return $hasChildren; |
| 1081 | 1078 | } |
@@ -1087,14 +1084,14 @@ discard block |
||
| 1087 | 1084 | */ |
| 1088 | 1085 | protected function collectChildren($parent, &$nodes) |
| 1089 | 1086 | { |
| 1090 | - $noChildren = !$this->hasChildren($nodes); |
|
| 1091 | - $childs = array(); |
|
| 1092 | - for(reset($nodes); $key = key($nodes);) |
|
| 1087 | + $noChildren=!$this->hasChildren($nodes); |
|
| 1088 | + $childs=array(); |
|
| 1089 | + for(reset($nodes); $key=key($nodes);) |
|
| 1093 | 1090 | { |
| 1094 | 1091 | next($nodes); |
| 1095 | 1092 | if($noChildren) |
| 1096 | 1093 | { |
| 1097 | - $childs[] = $key; |
|
| 1094 | + $childs[]=$key; |
|
| 1098 | 1095 | unset($nodes[$key]); |
| 1099 | 1096 | } |
| 1100 | 1097 | else |
@@ -1114,17 +1111,17 @@ discard block |
||
| 1114 | 1111 | if(empty($parent) || empty($this->_entries[$parent])) |
| 1115 | 1112 | return; |
| 1116 | 1113 | |
| 1117 | - $parentObject = $this->_entries[$parent]['object']; |
|
| 1118 | - $property = $this->_entries[$nodes[0]]['property']; |
|
| 1114 | + $parentObject=$this->_entries[$parent]['object']; |
|
| 1115 | + $property=$this->_entries[$nodes[0]]['property']; |
|
| 1119 | 1116 | |
| 1120 | - $list = TPropertyAccess::get($parentObject, $property); |
|
| 1117 | + $list=TPropertyAccess::get($parentObject, $property); |
|
| 1121 | 1118 | |
| 1122 | 1119 | foreach($nodes as $node) |
| 1123 | 1120 | { |
| 1124 | 1121 | if($list instanceof TList) |
| 1125 | - $parentObject->{$property}[] = $this->_entries[$node]['object']; |
|
| 1122 | + $parentObject->{$property}[]=$this->_entries[$node]['object']; |
|
| 1126 | 1123 | else if(is_array($list)) |
| 1127 | - $list[] = $this->_entries[$node]['object']; |
|
| 1124 | + $list[]=$this->_entries[$node]['object']; |
|
| 1128 | 1125 | else |
| 1129 | 1126 | throw new TSqlMapExecutionException( |
| 1130 | 1127 | 'sqlmap_property_must_be_list'); |
@@ -1133,8 +1130,8 @@ discard block |
||
| 1133 | 1130 | if(is_array($list)) |
| 1134 | 1131 | TPropertyAccess::set($parentObject, $property, $list); |
| 1135 | 1132 | |
| 1136 | - if($this->_entries[$parent]['property'] === null) |
|
| 1137 | - $this->_list[] = $parentObject; |
|
| 1133 | + if($this->_entries[$parent]['property']===null) |
|
| 1134 | + $this->_list[]=$parentObject; |
|
| 1138 | 1135 | } |
| 1139 | 1136 | |
| 1140 | 1137 | /** |
@@ -1147,11 +1144,11 @@ discard block |
||
| 1147 | 1144 | |
| 1148 | 1145 | public function __sleep() |
| 1149 | 1146 | { |
| 1150 | - $exprops = array(); $cn = __CLASS__; |
|
| 1151 | - if (!count($this->_tree)) $exprops[] = "\0$cn\0_tree"; |
|
| 1152 | - if (!count($this->_entries)) $exprops[] = "\0$cn\0_entries"; |
|
| 1153 | - if (!count($this->_list)) $exprops[] = "\0$cn\0_list"; |
|
| 1154 | - return array_diff(parent::__sleep(),$exprops); |
|
| 1147 | + $exprops=array(); $cn=__CLASS__; |
|
| 1148 | + if(!count($this->_tree)) $exprops[]="\0$cn\0_tree"; |
|
| 1149 | + if(!count($this->_entries)) $exprops[]="\0$cn\0_entries"; |
|
| 1150 | + if(!count($this->_list)) $exprops[]="\0$cn\0_list"; |
|
| 1151 | + return array_diff(parent::__sleep(), $exprops); |
|
| 1155 | 1152 | } |
| 1156 | 1153 | } |
| 1157 | 1154 | |
@@ -1170,9 +1167,9 @@ discard block |
||
| 1170 | 1167 | |
| 1171 | 1168 | public function __construct($result, $parameter, &$list) |
| 1172 | 1169 | { |
| 1173 | - $this->_resultObject = $result; |
|
| 1174 | - $this->_parameterObject = $parameter; |
|
| 1175 | - $this->_list = &$list; |
|
| 1170 | + $this->_resultObject=$result; |
|
| 1171 | + $this->_parameterObject=$parameter; |
|
| 1172 | + $this->_list=&$list; |
|
| 1176 | 1173 | } |
| 1177 | 1174 | |
| 1178 | 1175 | public function getResult() |
@@ -1207,10 +1204,10 @@ discard block |
||
| 1207 | 1204 | |
| 1208 | 1205 | public function __construct($key, $value, $parameter, &$map) |
| 1209 | 1206 | { |
| 1210 | - $this->_key = $key; |
|
| 1211 | - $this->_value = $value; |
|
| 1212 | - $this->_parameterObject = $parameter; |
|
| 1213 | - $this->_map = &$map; |
|
| 1207 | + $this->_key=$key; |
|
| 1208 | + $this->_value=$value; |
|
| 1209 | + $this->_parameterObject=$parameter; |
|
| 1210 | + $this->_map=&$map; |
|
| 1214 | 1211 | } |
| 1215 | 1212 | |
| 1216 | 1213 | public function getKey() |
@@ -237,8 +237,7 @@ discard block |
||
| 237 | 237 | $param = new TResultSetListItemParameter($obj, $parameter, $list); |
| 238 | 238 | $this->raiseRowDelegate($delegate, $param); |
| 239 | 239 | } |
| 240 | - } |
|
| 241 | - else |
|
| 240 | + } else |
|
| 242 | 241 | { |
| 243 | 242 | //var_dump($sql,$parameter); |
| 244 | 243 | foreach($reader as $row) |
@@ -314,8 +313,7 @@ discard block |
||
| 314 | 313 | $param = new TResultSetMapItemParameter($key, $value, $parameter, $map); |
| 315 | 314 | $this->raiseRowDelegate($delegate, $param); |
| 316 | 315 | } |
| 317 | - } |
|
| 318 | - else |
|
| 316 | + } else |
|
| 319 | 317 | { |
| 320 | 318 | //while($row = $recordSet->fetchRow()) |
| 321 | 319 | foreach($reader as $row) |
@@ -341,8 +339,7 @@ discard block |
||
| 341 | 339 | if(is_string($handler)) |
| 342 | 340 | { |
| 343 | 341 | call_user_func($handler,$this,$param); |
| 344 | - } |
|
| 345 | - else if(is_callable($handler,true)) |
|
| 342 | + } else if(is_callable($handler,true)) |
|
| 346 | 343 | { |
| 347 | 344 | // an array: 0 - object, 1 - method name/path |
| 348 | 345 | list($object,$method)=$handler; |
@@ -357,8 +354,7 @@ discard block |
||
| 357 | 354 | } |
| 358 | 355 | $object->$method($this,$param); |
| 359 | 356 | } |
| 360 | - } |
|
| 361 | - else |
|
| 357 | + } else |
|
| 362 | 358 | throw new TInvalidDataValueException('sqlmap_invalid_delegate', $this->getID(), $handler); |
| 363 | 359 | } |
| 364 | 360 | |
@@ -520,8 +516,7 @@ discard block |
||
| 520 | 516 | if($method == self::QUERY_FOR_ARRAY) |
| 521 | 517 | $values = $values->toArray(); |
| 522 | 518 | TPropertyAccess::set($resultObject, $property, $values); |
| 523 | - } |
|
| 524 | - else if($method == self::QUERY_FOR_OBJECT) |
|
| 519 | + } else if($method == self::QUERY_FOR_OBJECT) |
|
| 525 | 520 | { |
| 526 | 521 | $value = $statement->executeQueryForObject($connection, $keys, null); |
| 527 | 522 | TPropertyAccess::set($resultObject, $property, $value); |
@@ -651,8 +646,7 @@ discard block |
||
| 651 | 646 | else |
| 652 | 647 | foreach($resultMap->getColumns() as $property) |
| 653 | 648 | $this->setObjectProperty($resultMap, $property, $row, $resultObject); |
| 654 | - } |
|
| 655 | - else |
|
| 649 | + } else |
|
| 656 | 650 | { |
| 657 | 651 | $resultObject = $this->fillDefaultResultMap($resultMap, $row, $resultObject); |
| 658 | 652 | } |
@@ -797,8 +791,7 @@ discard block |
||
| 797 | 791 | if($key === '') |
| 798 | 792 | { |
| 799 | 793 | $resultObject = $property->getPropertyValue($registry,$row); |
| 800 | - } |
|
| 801 | - else if(strlen($select) == 0 && ($nested===null)) |
|
| 794 | + } else if(strlen($select) == 0 && ($nested===null)) |
|
| 802 | 795 | { |
| 803 | 796 | $value = $property->getPropertyValue($registry,$row); |
| 804 | 797 | |
@@ -807,8 +800,7 @@ discard block |
||
| 807 | 800 | TPropertyAccess::set($resultObject, $key, $value); |
| 808 | 801 | else |
| 809 | 802 | $resultObject = $value; |
| 810 | - } |
|
| 811 | - else if($nested!==null) |
|
| 803 | + } else if($nested!==null) |
|
| 812 | 804 | { |
| 813 | 805 | if($property->instanceOfListType($resultObject) || $property->instanceOfArrayType($resultObject)) |
| 814 | 806 | { |
@@ -816,16 +808,14 @@ discard block |
||
| 816 | 808 | throw new TSqlMapExecutionException( |
| 817 | 809 | 'sqlmap_non_groupby_array_list_type', $resultMap->getID(), |
| 818 | 810 | get_class($resultObject), $key); |
| 819 | - } |
|
| 820 | - else |
|
| 811 | + } else |
|
| 821 | 812 | { |
| 822 | 813 | $obj = $nested->createInstanceOfResult($this->getManager()->getTypeHandlers()); |
| 823 | 814 | if($this->fillPropertyWithResultMap($nested, $row, $obj) == false) |
| 824 | 815 | $obj = null; |
| 825 | 816 | TPropertyAccess::set($resultObject, $key, $obj); |
| 826 | 817 | } |
| 827 | - } |
|
| 828 | - else //'select' ResultProperty |
|
| 818 | + } else //'select' ResultProperty |
|
| 829 | 819 | { |
| 830 | 820 | $this->enquequePostSelect($select, $resultMap, $property, $row, $resultObject); |
| 831 | 821 | } |
@@ -857,11 +847,9 @@ discard block |
||
| 857 | 847 | $values = TLazyLoadList::newInstance($statement, $key, |
| 858 | 848 | $resultObject, $property->getProperty()); |
| 859 | 849 | TPropertyAccess::set($resultObject, $property->getProperty(), $values); |
| 860 | - } |
|
| 861 | - else |
|
| 850 | + } else |
|
| 862 | 851 | $postSelect->setMethod(self::QUERY_FOR_LIST); |
| 863 | - } |
|
| 864 | - else if($property->instanceOfArrayType($resultObject)) |
|
| 852 | + } else if($property->instanceOfArrayType($resultObject)) |
|
| 865 | 853 | $postSelect->setMethod(self::QUERY_FOR_ARRAY); |
| 866 | 854 | else |
| 867 | 855 | $postSelect->setMethod(self::QUERY_FOR_OBJECT); |
@@ -889,8 +877,7 @@ discard block |
||
| 889 | 877 | $keys[trim($pair[0])] = $row[trim($pair[1])]; |
| 890 | 878 | } |
| 891 | 879 | return $keys; |
| 892 | - } |
|
| 893 | - else |
|
| 880 | + } else |
|
| 894 | 881 | { |
| 895 | 882 | $registry=$this->getManager()->getTypeHandlers(); |
| 896 | 883 | return $property->getPropertyValue($registry,$row); |
@@ -1048,8 +1035,7 @@ discard block |
||
| 1048 | 1035 | { |
| 1049 | 1036 | $found = true; |
| 1050 | 1037 | $childs[$key][$node] = array(); |
| 1051 | - } |
|
| 1052 | - else |
|
| 1038 | + } else |
|
| 1053 | 1039 | { |
| 1054 | 1040 | $found = $found || $this->addNode($childs[$key], $parent, $node); |
| 1055 | 1041 | } |
@@ -1062,8 +1048,9 @@ discard block |
||
| 1062 | 1048 | */ |
| 1063 | 1049 | public function collect() |
| 1064 | 1050 | { |
| 1065 | - while(count($this->_tree) > 0) |
|
| 1066 | - $this->collectChildren(null, $this->_tree); |
|
| 1051 | + while(count($this->_tree) > 0) { |
|
| 1052 | + $this->collectChildren(null, $this->_tree); |
|
| 1053 | + } |
|
| 1067 | 1054 | return $this->getCollection(); |
| 1068 | 1055 | } |
| 1069 | 1056 | |
@@ -1096,8 +1083,7 @@ discard block |
||
| 1096 | 1083 | { |
| 1097 | 1084 | $childs[] = $key; |
| 1098 | 1085 | unset($nodes[$key]); |
| 1099 | - } |
|
| 1100 | - else |
|
| 1086 | + } else |
|
| 1101 | 1087 | $this->collectChildren($key, $nodes[$key]); |
| 1102 | 1088 | } |
| 1103 | 1089 | if(count($childs) > 0) |
@@ -21,6 +21,9 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | class TPreparedCommand |
| 23 | 23 | { |
| 24 | + /** |
|
| 25 | + * @param TSqlMapStatement $statement |
|
| 26 | + */ |
|
| 24 | 27 | public function create(TSqlMapManager $manager, $connection, $statement, $parameterObject,$skip=null,$max=null) |
| 25 | 28 | { |
| 26 | 29 | $sqlText = $statement->getSQLText(); |
@@ -43,6 +46,9 @@ discard block |
||
| 43 | 46 | return $command; |
| 44 | 47 | } |
| 45 | 48 | |
| 49 | + /** |
|
| 50 | + * @param TSqlMapManager $manager |
|
| 51 | + */ |
|
| 46 | 52 | protected function applyParameterMap($manager,$command,$prepared, $statement, $parameterObject) |
| 47 | 53 | { |
| 48 | 54 | $properties = $prepared->getParameterNames(false); |
@@ -21,45 +21,45 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | class TPreparedCommand |
| 23 | 23 | { |
| 24 | - public function create(TSqlMapManager $manager, $connection, $statement, $parameterObject,$skip=null,$max=null) |
|
| 24 | + public function create(TSqlMapManager $manager, $connection, $statement, $parameterObject, $skip=null, $max=null) |
|
| 25 | 25 | { |
| 26 | - $sqlText = $statement->getSQLText(); |
|
| 26 | + $sqlText=$statement->getSQLText(); |
|
| 27 | 27 | |
| 28 | - $prepared = $sqlText->getPreparedStatement($parameterObject); |
|
| 28 | + $prepared=$sqlText->getPreparedStatement($parameterObject); |
|
| 29 | 29 | $connection->setActive(true); |
| 30 | - $sql = $prepared->getPreparedSql(); |
|
| 30 | + $sql=$prepared->getPreparedSql(); |
|
| 31 | 31 | |
| 32 | 32 | if($sqlText instanceof TSimpleDynamicSql) |
| 33 | - $sql = $sqlText->replaceDynamicParameter($sql, $parameterObject); |
|
| 33 | + $sql=$sqlText->replaceDynamicParameter($sql, $parameterObject); |
|
| 34 | 34 | |
| 35 | 35 | if($max!==null || $skip!==null) |
| 36 | 36 | { |
| 37 | - $builder = TDbMetaData::getInstance($connection)->createCommandBuilder(); |
|
| 38 | - $sql = $builder->applyLimitOffset($sql,$max,$skip); |
|
| 37 | + $builder=TDbMetaData::getInstance($connection)->createCommandBuilder(); |
|
| 38 | + $sql=$builder->applyLimitOffset($sql, $max, $skip); |
|
| 39 | 39 | } |
| 40 | - $command = $connection->createCommand($sql); |
|
| 40 | + $command=$connection->createCommand($sql); |
|
| 41 | 41 | $this->applyParameterMap($manager, $command, $prepared, $statement, $parameterObject); |
| 42 | 42 | |
| 43 | 43 | return $command; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - protected function applyParameterMap($manager,$command,$prepared, $statement, $parameterObject) |
|
| 46 | + protected function applyParameterMap($manager, $command, $prepared, $statement, $parameterObject) |
|
| 47 | 47 | { |
| 48 | - $properties = $prepared->getParameterNames(false); |
|
| 48 | + $properties=$prepared->getParameterNames(false); |
|
| 49 | 49 | //$parameters = $prepared->getParameterValues(); |
| 50 | 50 | $registry=$manager->getTypeHandlers(); |
| 51 | - if ($properties) |
|
| 52 | - for($i = 0, $k=$properties->getCount(); $i<$k; $i++) |
|
| 51 | + if($properties) |
|
| 52 | + for($i=0, $k=$properties->getCount(); $i < $k; $i++) |
|
| 53 | 53 | { |
| 54 | - $property = $statement->parameterMap()->getProperty($i); |
|
| 55 | - $value = $statement->parameterMap()->getPropertyValue($registry,$property, $parameterObject); |
|
| 56 | - $dbType = $property->getDbType(); |
|
| 54 | + $property=$statement->parameterMap()->getProperty($i); |
|
| 55 | + $value=$statement->parameterMap()->getPropertyValue($registry, $property, $parameterObject); |
|
| 56 | + $dbType=$property->getDbType(); |
|
| 57 | 57 | if($dbType=='') //relies on PHP lax comparison |
| 58 | - $command->bindValue($i+1,$value, TDbCommandBuilder::getPdoType($value)); |
|
| 58 | + $command->bindValue($i + 1, $value, TDbCommandBuilder::getPdoType($value)); |
|
| 59 | 59 | else if(strpos($dbType, 'PDO::')===0) |
| 60 | - $command->bindValue($i+1,$value, constant($property->getDbType())); //assumes PDO types, e.g. PDO::PARAM_INT |
|
| 60 | + $command->bindValue($i + 1, $value, constant($property->getDbType())); //assumes PDO types, e.g. PDO::PARAM_INT |
|
| 61 | 61 | else |
| 62 | - $command->bindValue($i+1,$value); |
|
| 62 | + $command->bindValue($i + 1, $value); |
|
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -77,6 +77,7 @@ |
||
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * Saves the current SqlMap manager to cache. |
| 80 | + * @param TSqlMapManager $manager |
|
| 80 | 81 | * @return boolean true if SqlMap manager was cached, false otherwise. |
| 81 | 82 | */ |
| 82 | 83 | protected function cacheSqlMapManager($manager) |
@@ -68,8 +68,7 @@ |
||
| 68 | 68 | $manager->configureXml($file); |
| 69 | 69 | $this->cacheSqlMapManager($manager); |
| 70 | 70 | } |
| 71 | - } |
|
| 72 | - elseif($this->getConnectionID() !== '') { |
|
| 71 | + } elseif($this->getConnectionID() !== '') { |
|
| 73 | 72 | $manager->setDbConnection($this->getDbConnection()); |
| 74 | 73 | } |
| 75 | 74 | return $manager; |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | public function clearCache() |
| 46 | 46 | { |
| 47 | - $cache = $this->getApplication()->getCache(); |
|
| 48 | - if($cache !== null) { |
|
| 47 | + $cache=$this->getApplication()->getCache(); |
|
| 48 | + if($cache!==null) { |
|
| 49 | 49 | $cache->delete($this->getCacheKey()); |
| 50 | 50 | } |
| 51 | 51 | } |
@@ -60,16 +60,16 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | public function getSqlMapManager() { |
| 62 | 62 | Prado::using('System.Data.SqlMap.TSqlMapManager'); |
| 63 | - if(($manager = $this->loadCachedSqlMapManager())===null) |
|
| 63 | + if(($manager=$this->loadCachedSqlMapManager())===null) |
|
| 64 | 64 | { |
| 65 | - $manager = new TSqlMapManager($this->getDbConnection()); |
|
| 65 | + $manager=new TSqlMapManager($this->getDbConnection()); |
|
| 66 | 66 | if(strlen($file=$this->getConfigFile()) > 0) |
| 67 | 67 | { |
| 68 | 68 | $manager->configureXml($file); |
| 69 | 69 | $this->cacheSqlMapManager($manager); |
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | - elseif($this->getConnectionID() !== '') { |
|
| 72 | + elseif($this->getConnectionID()!=='') { |
|
| 73 | 73 | $manager->setDbConnection($this->getDbConnection()); |
| 74 | 74 | } |
| 75 | 75 | return $manager; |
@@ -83,11 +83,11 @@ discard block |
||
| 83 | 83 | { |
| 84 | 84 | if($this->getEnableCache()) |
| 85 | 85 | { |
| 86 | - $cache = $this->getApplication()->getCache(); |
|
| 87 | - if($cache !== null) { |
|
| 88 | - $dependencies = null; |
|
| 89 | - if($this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
| 90 | - $dependencies = $manager->getCacheDependencies(); |
|
| 86 | + $cache=$this->getApplication()->getCache(); |
|
| 87 | + if($cache!==null) { |
|
| 88 | + $dependencies=null; |
|
| 89 | + if($this->getApplication()->getMode()!==TApplicationMode::Performance) |
|
| 90 | + $dependencies=$manager->getCacheDependencies(); |
|
| 91 | 91 | return $cache->set($this->getCacheKey(), $manager, 0, $dependencies); |
| 92 | 92 | } |
| 93 | 93 | } |
@@ -102,10 +102,10 @@ discard block |
||
| 102 | 102 | { |
| 103 | 103 | if($this->getEnableCache()) |
| 104 | 104 | { |
| 105 | - $cache = $this->getApplication()->getCache(); |
|
| 106 | - if($cache !== null) |
|
| 105 | + $cache=$this->getApplication()->getCache(); |
|
| 106 | + if($cache!==null) |
|
| 107 | 107 | { |
| 108 | - $manager = $cache->get($this->getCacheKey()); |
|
| 108 | + $manager=$cache->get($this->getCacheKey()); |
|
| 109 | 109 | if($manager instanceof TSqlMapManager) |
| 110 | 110 | return $manager; |
| 111 | 111 | } |
@@ -132,11 +132,11 @@ discard block |
||
| 132 | 132 | $this->_configFile=$value; |
| 133 | 133 | else |
| 134 | 134 | { |
| 135 | - $file = Prado::getPathOfNamespace($value,self::CONFIG_FILE_EXT); |
|
| 136 | - if($file === null || !is_file($file)) |
|
| 137 | - throw new TConfigurationException('sqlmap_configfile_invalid',$value); |
|
| 135 | + $file=Prado::getPathOfNamespace($value, self::CONFIG_FILE_EXT); |
|
| 136 | + if($file===null || !is_file($file)) |
|
| 137 | + throw new TConfigurationException('sqlmap_configfile_invalid', $value); |
|
| 138 | 138 | else |
| 139 | - $this->_configFile = $file; |
|
| 139 | + $this->_configFile=$file; |
|
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | public function setEnableCache($value) |
| 148 | 148 | { |
| 149 | - $this->_enableCache = TPropertyValue::ensureBoolean($value); |
|
| 149 | + $this->_enableCache=TPropertyValue::ensureBoolean($value); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | /** |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | */ |
| 172 | 172 | public function getClient() |
| 173 | 173 | { |
| 174 | - if($this->_sqlmap===null ) |
|
| 174 | + if($this->_sqlmap===null) |
|
| 175 | 175 | $this->_sqlmap=$this->createSqlMapGateway(); |
| 176 | 176 | return $this->_sqlmap; |
| 177 | 177 | } |
@@ -55,6 +55,7 @@ discard block |
||
| 55 | 55 | * Constructor, create a new SqlMap manager. |
| 56 | 56 | * @param TDbConnection database connection |
| 57 | 57 | * @param string configuration file. |
| 58 | + * @param TDbConnection $connection |
|
| 58 | 59 | */ |
| 59 | 60 | public function __construct($connection=null) |
| 60 | 61 | { |
@@ -68,6 +69,7 @@ discard block |
||
| 68 | 69 | |
| 69 | 70 | /** |
| 70 | 71 | * @param TDbConnection default database connection |
| 72 | + * @param TComponent $conn |
|
| 71 | 73 | */ |
| 72 | 74 | public function setDbConnection($conn) |
| 73 | 75 | { |
@@ -105,6 +107,7 @@ discard block |
||
| 105 | 107 | /** |
| 106 | 108 | * Loads and parses the SqlMap configuration file. |
| 107 | 109 | * @param string xml configuration file. |
| 110 | + * @param string $file |
|
| 108 | 111 | */ |
| 109 | 112 | public function configureXml($file) |
| 110 | 113 | { |
@@ -180,6 +183,7 @@ discard block |
||
| 180 | 183 | /** |
| 181 | 184 | * Gets a named result map |
| 182 | 185 | * @param string result name. |
| 186 | + * @param string $name |
|
| 183 | 187 | * @return TResultMap the result map. |
| 184 | 188 | * @throws TSqlMapUndefinedException |
| 185 | 189 | */ |
@@ -212,6 +216,7 @@ discard block |
||
| 212 | 216 | |
| 213 | 217 | /** |
| 214 | 218 | * @param string parameter map ID name. |
| 219 | + * @param string $name |
|
| 215 | 220 | * @return TParameterMap the parameter with given ID. |
| 216 | 221 | * @throws TSqlMapUndefinedException |
| 217 | 222 | */ |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | public function getTypeHandlers() |
| 89 | 89 | { |
| 90 | 90 | if($this->_typeHandlers===null) |
| 91 | - $this->_typeHandlers= new TSqlMapTypeHandlerRegistry(); |
|
| 91 | + $this->_typeHandlers=new TSqlMapTypeHandlerRegistry(); |
|
| 92 | 92 | return $this->_typeHandlers; |
| 93 | 93 | } |
| 94 | 94 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function configureXml($file) |
| 110 | 110 | { |
| 111 | - $config = new TSqlMapXmlConfiguration($this); |
|
| 111 | + $config=new TSqlMapXmlConfiguration($this); |
|
| 112 | 112 | $config->configure($file); |
| 113 | 113 | } |
| 114 | 114 | |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | public function getCacheDependencies() |
| 120 | 120 | { |
| 121 | - if($this->_cacheDependencies === null) |
|
| 121 | + if($this->_cacheDependencies===null) |
|
| 122 | 122 | $this->_cacheDependencies=new TChainedCacheDependency(); |
| 123 | 123 | |
| 124 | 124 | return $this->_cacheDependencies; |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | */ |
| 151 | 151 | public function getMappedStatement($name) |
| 152 | 152 | { |
| 153 | - if($this->_mappedStatements->contains($name) == false) |
|
| 153 | + if($this->_mappedStatements->contains($name)==false) |
|
| 154 | 154 | throw new TSqlMapUndefinedException('sqlmap_contains_no_statement', $name); |
| 155 | 155 | return $this->_mappedStatements[$name]; |
| 156 | 156 | } |
@@ -163,8 +163,8 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | public function addMappedStatement(IMappedStatement $statement) |
| 165 | 165 | { |
| 166 | - $key = $statement->getID(); |
|
| 167 | - if($this->_mappedStatements->contains($key) == true) |
|
| 166 | + $key=$statement->getID(); |
|
| 167 | + if($this->_mappedStatements->contains($key)==true) |
|
| 168 | 168 | throw new TSqlMapDuplicateException('sqlmap_already_contains_statement', $key); |
| 169 | 169 | $this->_mappedStatements->add($key, $statement); |
| 170 | 170 | } |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | */ |
| 186 | 186 | public function getResultMap($name) |
| 187 | 187 | { |
| 188 | - if($this->_resultMaps->contains($name) == false) |
|
| 188 | + if($this->_resultMaps->contains($name)==false) |
|
| 189 | 189 | throw new TSqlMapUndefinedException('sqlmap_contains_no_result_map', $name); |
| 190 | 190 | return $this->_resultMaps[$name]; |
| 191 | 191 | } |
@@ -196,8 +196,8 @@ discard block |
||
| 196 | 196 | */ |
| 197 | 197 | public function addResultMap(TResultMap $result) |
| 198 | 198 | { |
| 199 | - $key = $result->getID(); |
|
| 200 | - if($this->_resultMaps->contains($key) == true) |
|
| 199 | + $key=$result->getID(); |
|
| 200 | + if($this->_resultMaps->contains($key)==true) |
|
| 201 | 201 | throw new TSqlMapDuplicateException('sqlmap_already_contains_result_map', $key); |
| 202 | 202 | $this->_resultMaps->add($key, $result); |
| 203 | 203 | } |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | */ |
| 218 | 218 | public function getParameterMap($name) |
| 219 | 219 | { |
| 220 | - if($this->_parameterMaps->contains($name) == false) |
|
| 220 | + if($this->_parameterMaps->contains($name)==false) |
|
| 221 | 221 | throw new TSqlMapUndefinedException('sqlmap_contains_no_parameter_map', $name); |
| 222 | 222 | return $this->_parameterMaps[$name]; |
| 223 | 223 | } |
@@ -228,8 +228,8 @@ discard block |
||
| 228 | 228 | */ |
| 229 | 229 | public function addParameterMap(TParameterMap $parameter) |
| 230 | 230 | { |
| 231 | - $key = $parameter->getID(); |
|
| 232 | - if($this->_parameterMaps->contains($key) == true) |
|
| 231 | + $key=$parameter->getID(); |
|
| 232 | + if($this->_parameterMaps->contains($key)==true) |
|
| 233 | 233 | throw new TSqlMapDuplicateException('sqlmap_already_contains_parameter_map', $key); |
| 234 | 234 | $this->_parameterMaps->add($key, $parameter); |
| 235 | 235 | } |
@@ -149,6 +149,7 @@ |
||
| 149 | 149 | /** |
| 150 | 150 | * Finds the database connection instance from the Application modules. |
| 151 | 151 | * @param string Database connection module ID. |
| 152 | + * @param string $id |
|
| 152 | 153 | * @return TDbConnection database connection. |
| 153 | 154 | * @throws TConfigurationException when module is not of TDbConnection or TDataSourceConfig. |
| 154 | 155 | */ |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | { |
| 63 | 63 | $db=$this->getDbConnection(); |
| 64 | 64 | foreach($xml['database'] as $name=>$value) |
| 65 | - $db->setSubProperty($name,$value); |
|
| 65 | + $db->setSubProperty($name, $value); |
|
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | else |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | { |
| 72 | 72 | $db=$this->getDbConnection(); |
| 73 | 73 | foreach($prop->getAttributes() as $name=>$value) |
| 74 | - $db->setSubproperty($name,$value); |
|
| 74 | + $db->setSubproperty($name, $value); |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | } |
@@ -106,9 +106,9 @@ discard block |
||
| 106 | 106 | if($this->_conn===null) |
| 107 | 107 | { |
| 108 | 108 | if($this->_connID!=='') |
| 109 | - $this->_conn = $this->findConnectionByID($this->getConnectionID()); |
|
| 109 | + $this->_conn=$this->findConnectionByID($this->getConnectionID()); |
|
| 110 | 110 | else |
| 111 | - $this->_conn = Prado::createComponent($this->getConnectionClass()); |
|
| 111 | + $this->_conn=Prado::createComponent($this->getConnectionClass()); |
|
| 112 | 112 | } |
| 113 | 113 | return $this->_conn; |
| 114 | 114 | } |
@@ -154,12 +154,12 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | protected function findConnectionByID($id) |
| 156 | 156 | { |
| 157 | - $conn = $this->getApplication()->getModule($id); |
|
| 157 | + $conn=$this->getApplication()->getModule($id); |
|
| 158 | 158 | if($conn instanceof TDbConnection) |
| 159 | 159 | return $conn; |
| 160 | 160 | else if($conn instanceof TDataSourceConfig) |
| 161 | 161 | return $conn->getDbConnection(); |
| 162 | 162 | else |
| 163 | - throw new TConfigurationException('datasource_dbconnection_invalid',$id); |
|
| 163 | + throw new TConfigurationException('datasource_dbconnection_invalid', $id); |
|
| 164 | 164 | } |
| 165 | 165 | } |
@@ -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 | } |
@@ -157,6 +157,7 @@ discard block |
||
| 157 | 157 | /** |
| 158 | 158 | * Open or close the DB connection. |
| 159 | 159 | * @param boolean whether to open or close DB connection |
| 160 | + * @param boolean $value |
|
| 160 | 161 | * @throws TDbException if connection fails |
| 161 | 162 | */ |
| 162 | 163 | public function setActive($value) |
@@ -241,6 +242,7 @@ discard block |
||
| 241 | 242 | |
| 242 | 243 | /** |
| 243 | 244 | * @param string The Data Source Name, or DSN, contains the information required to connect to the database. |
| 245 | + * @param string $value |
|
| 244 | 246 | * @see http://www.php.net/manual/en/function.PDO-construct.php |
| 245 | 247 | */ |
| 246 | 248 | public function setConnectionString($value) |
@@ -258,6 +260,7 @@ discard block |
||
| 258 | 260 | |
| 259 | 261 | /** |
| 260 | 262 | * @param string the username for establishing DB connection |
| 263 | + * @param string $value |
|
| 261 | 264 | */ |
| 262 | 265 | public function setUsername($value) |
| 263 | 266 | { |
@@ -274,6 +277,7 @@ discard block |
||
| 274 | 277 | |
| 275 | 278 | /** |
| 276 | 279 | * @param string the password for establishing DB connection |
| 280 | + * @param string $value |
|
| 277 | 281 | */ |
| 278 | 282 | public function setPassword($value) |
| 279 | 283 | { |
@@ -189,8 +189,7 @@ discard block |
||
| 189 | 189 | $this->_pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 190 | 190 | $this->_active=true; |
| 191 | 191 | $this->setConnectionCharset(); |
| 192 | - } |
|
| 193 | - catch(PDOException $e) |
|
| 192 | + } catch(PDOException $e) |
|
| 194 | 193 | { |
| 195 | 194 | throw new TDbException('dbconnection_open_failed',$e->getMessage()); |
| 196 | 195 | } |
@@ -343,8 +342,7 @@ discard block |
||
| 343 | 342 | { |
| 344 | 343 | $this->_pdo->beginTransaction(); |
| 345 | 344 | return $this->_transaction=Prado::createComponent($this->getTransactionClass(), $this); |
| 346 | - } |
|
| 347 | - else |
|
| 345 | + } else |
|
| 348 | 346 | throw new TDbException('dbconnection_connection_inactive'); |
| 349 | 347 | } |
| 350 | 348 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | * |
| 86 | 86 | * @since 3.1.7 |
| 87 | 87 | */ |
| 88 | - const DEFAULT_TRANSACTION_CLASS = 'System.Data.TDbTransaction'; |
|
| 88 | + const DEFAULT_TRANSACTION_CLASS='System.Data.TDbTransaction'; |
|
| 89 | 89 | |
| 90 | 90 | private $_dsn=''; |
| 91 | 91 | private $_username=''; |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | /** |
| 100 | 100 | * @var TDbMetaData |
| 101 | 101 | */ |
| 102 | - private $_dbMeta = null; |
|
| 102 | + private $_dbMeta=null; |
|
| 103 | 103 | |
| 104 | 104 | /** |
| 105 | 105 | * @var string |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | * @param string Charset used for DB Connection (MySql & pgsql only). If not set, will use the default charset of your database server |
| 121 | 121 | * @see http://www.php.net/manual/en/function.PDO-construct.php |
| 122 | 122 | */ |
| 123 | - public function __construct($dsn='',$username='',$password='', $charset='') |
|
| 123 | + public function __construct($dsn='', $username='', $password='', $charset='') |
|
| 124 | 124 | { |
| 125 | 125 | $this->_dsn=$dsn; |
| 126 | 126 | $this->_username=$username; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | public function __sleep() |
| 135 | 135 | { |
| 136 | 136 | // $this->close(); - DO NOT CLOSE the current connection as serializing doesn't neccessarily mean we don't this connection anymore in the current session |
| 137 | - return array_diff(parent::__sleep(),array("\0TDbConnection\0_pdo","\0TDbConnection\0_active")); |
|
| 137 | + return array_diff(parent::__sleep(), array("\0TDbConnection\0_pdo", "\0TDbConnection\0_active")); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -181,8 +181,8 @@ discard block |
||
| 181 | 181 | { |
| 182 | 182 | try |
| 183 | 183 | { |
| 184 | - $this->_pdo=new PDO($this->getConnectionString(),$this->getUsername(), |
|
| 185 | - $this->getPassword(),$this->_attributes); |
|
| 184 | + $this->_pdo=new PDO($this->getConnectionString(), $this->getUsername(), |
|
| 185 | + $this->getPassword(), $this->_attributes); |
|
| 186 | 186 | // This attribute is only useful for PDO::MySql driver. |
| 187 | 187 | // Ignore the warning if a driver doesn't understand this. |
| 188 | 188 | @$this->_pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | } |
| 193 | 193 | catch(PDOException $e) |
| 194 | 194 | { |
| 195 | - throw new TDbException('dbconnection_open_failed',$e->getMessage()); |
|
| 195 | + throw new TDbException('dbconnection_open_failed', $e->getMessage()); |
|
| 196 | 196 | } |
| 197 | 197 | } |
| 198 | 198 | } |
@@ -214,16 +214,16 @@ discard block |
||
| 214 | 214 | */ |
| 215 | 215 | protected function setConnectionCharset() |
| 216 | 216 | { |
| 217 | - if ($this->_charset === '' || $this->_active === false) |
|
| 217 | + if($this->_charset==='' || $this->_active===false) |
|
| 218 | 218 | return; |
| 219 | - switch ($this->_pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) |
|
| 219 | + switch($this->_pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) |
|
| 220 | 220 | { |
| 221 | 221 | case 'mysql': |
| 222 | 222 | case 'sqlite': |
| 223 | - $stmt = $this->_pdo->prepare('SET NAMES ?'); |
|
| 223 | + $stmt=$this->_pdo->prepare('SET NAMES ?'); |
|
| 224 | 224 | break; |
| 225 | 225 | case 'pgsql': |
| 226 | - $stmt = $this->_pdo->prepare('SET client_encoding TO ?'); |
|
| 226 | + $stmt=$this->_pdo->prepare('SET client_encoding TO ?'); |
|
| 227 | 227 | break; |
| 228 | 228 | default: |
| 229 | 229 | throw new TDbException('dbconnection_unsupported_driver_charset', $driver); |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | /** |
| 284 | 284 | * @return string the charset used for database connection. Defaults to emtpy string. |
| 285 | 285 | */ |
| 286 | - public function getCharset () |
|
| 286 | + public function getCharset() |
|
| 287 | 287 | { |
| 288 | 288 | return $this->_charset; |
| 289 | 289 | } |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | /** |
| 292 | 292 | * @param string the charset used for database connection |
| 293 | 293 | */ |
| 294 | - public function setCharset ($value) |
|
| 294 | + public function setCharset($value) |
|
| 295 | 295 | { |
| 296 | 296 | $this->_charset=$value; |
| 297 | 297 | $this->setConnectionCharset(); |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | public function createCommand($sql) |
| 315 | 315 | { |
| 316 | 316 | if($this->getActive()) |
| 317 | - return new TDbCommand($this,$sql); |
|
| 317 | + return new TDbCommand($this, $sql); |
|
| 318 | 318 | else |
| 319 | 319 | throw new TDbException('dbconnection_connection_inactive'); |
| 320 | 320 | } |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | */ |
| 365 | 365 | public function setTransactionClass($value) |
| 366 | 366 | { |
| 367 | - $this->_transactionClass = (string)$value; |
|
| 367 | + $this->_transactionClass=(string) $value; |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | /** |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | if($this->_dbMeta===null) |
| 434 | 434 | { |
| 435 | 435 | Prado::using('System.Data.Common.TDbMetaData'); |
| 436 | - $this->_dbMeta = TDbMetaData::getInstance($this); |
|
| 436 | + $this->_dbMeta=TDbMetaData::getInstance($this); |
|
| 437 | 437 | } |
| 438 | 438 | return $this->_dbMeta; |
| 439 | 439 | } |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | */ |
| 460 | 460 | public function setColumnCase($value) |
| 461 | 461 | { |
| 462 | - switch(TPropertyValue::ensureEnum($value,'TDbColumnCaseMode')) |
|
| 462 | + switch(TPropertyValue::ensureEnum($value, 'TDbColumnCaseMode')) |
|
| 463 | 463 | { |
| 464 | 464 | case TDbColumnCaseMode::Preserved: |
| 465 | 465 | $value=PDO::CASE_NATURAL; |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | $value=PDO::CASE_UPPER; |
| 472 | 472 | break; |
| 473 | 473 | } |
| 474 | - $this->setAttribute(PDO::ATTR_CASE,$value); |
|
| 474 | + $this->setAttribute(PDO::ATTR_CASE, $value); |
|
| 475 | 475 | } |
| 476 | 476 | |
| 477 | 477 | /** |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | */ |
| 496 | 496 | public function setNullConversion($value) |
| 497 | 497 | { |
| 498 | - switch(TPropertyValue::ensureEnum($value,'TDbNullConversionMode')) |
|
| 498 | + switch(TPropertyValue::ensureEnum($value, 'TDbNullConversionMode')) |
|
| 499 | 499 | { |
| 500 | 500 | case TDbNullConversionMode::Preserved: |
| 501 | 501 | $value=PDO::NULL_NATURAL; |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | $value=PDO::NULL_TO_STRING; |
| 508 | 508 | break; |
| 509 | 509 | } |
| 510 | - $this->setAttribute(PDO::ATTR_ORACLE_NULLS,$value); |
|
| 510 | + $this->setAttribute(PDO::ATTR_ORACLE_NULLS, $value); |
|
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | /** |
@@ -525,7 +525,7 @@ discard block |
||
| 525 | 525 | */ |
| 526 | 526 | public function setAutoCommit($value) |
| 527 | 527 | { |
| 528 | - $this->setAttribute(PDO::ATTR_AUTOCOMMIT,TPropertyValue::ensureBoolean($value)); |
|
| 528 | + $this->setAttribute(PDO::ATTR_AUTOCOMMIT, TPropertyValue::ensureBoolean($value)); |
|
| 529 | 529 | } |
| 530 | 530 | |
| 531 | 531 | /** |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | */ |
| 544 | 544 | public function setPersistent($value) |
| 545 | 545 | { |
| 546 | - return $this->setAttribute(PDO::ATTR_PERSISTENT,TPropertyValue::ensureBoolean($value)); |
|
| 546 | + return $this->setAttribute(PDO::ATTR_PERSISTENT, TPropertyValue::ensureBoolean($value)); |
|
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | /** |
@@ -623,10 +623,10 @@ discard block |
||
| 623 | 623 | * @param mixed the attribute value |
| 624 | 624 | * @see http://www.php.net/manual/en/function.PDO-setAttribute.php |
| 625 | 625 | */ |
| 626 | - public function setAttribute($name,$value) |
|
| 626 | + public function setAttribute($name, $value) |
|
| 627 | 627 | { |
| 628 | 628 | if($this->_pdo instanceof PDO) |
| 629 | - $this->_pdo->setAttribute($name,$value); |
|
| 629 | + $this->_pdo->setAttribute($name, $value); |
|
| 630 | 630 | else |
| 631 | 631 | $this->_attributes[$name]=$value; |
| 632 | 632 | } |
@@ -101,6 +101,7 @@ |
||
| 101 | 101 | |
| 102 | 102 | /** |
| 103 | 103 | * @param boolean whether this transaction is active |
| 104 | + * @param boolean $value |
|
| 104 | 105 | */ |
| 105 | 106 | protected function setActive($value) |
| 106 | 107 | { |
@@ -189,8 +189,7 @@ discard block |
||
| 189 | 189 | return file_put_contents($fileName,file_get_contents($this->_localName))!==false; |
| 190 | 190 | else |
| 191 | 191 | return false; |
| 192 | - } |
|
| 193 | - else |
|
| 192 | + } else |
|
| 194 | 193 | return false; |
| 195 | 194 | } |
| 196 | 195 | |
@@ -211,8 +210,7 @@ discard block |
||
| 211 | 210 | $this->_errorCode=$_FILES[$key]['error']; |
| 212 | 211 | $this->_localName=$_FILES[$key]['tmp_name']; |
| 213 | 212 | return $this->_dataChanged=true; |
| 214 | - } |
|
| 215 | - else |
|
| 213 | + } else |
|
| 216 | 214 | return false; |
| 217 | 215 | } |
| 218 | 216 | |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * TDbTransaction class file |
|
| 4 | - * |
|
| 5 | - * @author Qiang Xue <[email protected]> |
|
| 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 |
|
| 10 | - */ |
|
| 3 | + * TDbTransaction class file |
|
| 4 | + * |
|
| 5 | + * @author Qiang Xue <[email protected]> |
|
| 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 |
|
| 10 | + */ |
|
| 11 | 11 | |
| 12 | 12 | Prado::using('System.Data.TDbDataReader'); |
| 13 | 13 | |
@@ -200,6 +200,7 @@ discard block |
||
| 200 | 200 | |
| 201 | 201 | /** |
| 202 | 202 | * Gets the CultureInfo that for this culture string |
| 203 | + * @param string $culture |
|
| 203 | 204 | * @return CultureInfo invariant culture info is "en". |
| 204 | 205 | */ |
| 205 | 206 | public static function getInstance($culture) |
@@ -228,6 +229,7 @@ discard block |
||
| 228 | 229 | * Set the culture for the current instance. The culture indentifier |
| 229 | 230 | * must be of the form "<language>_(country/region)". |
| 230 | 231 | * @param string culture identifier, e.g. "fr_FR_EURO". |
| 232 | + * @param string $culture |
|
| 231 | 233 | */ |
| 232 | 234 | protected function setCulture($culture) |
| 233 | 235 | { |
@@ -243,6 +245,7 @@ discard block |
||
| 243 | 245 | /** |
| 244 | 246 | * Load the ICU culture data for the specific culture identifier. |
| 245 | 247 | * @param string the culture identifier. |
| 248 | + * @param string $culture |
|
| 246 | 249 | */ |
| 247 | 250 | protected function loadCultureData($culture) |
| 248 | 251 | { |
@@ -283,6 +286,7 @@ discard block |
||
| 283 | 286 | * The data files are cached in a static variable inside |
| 284 | 287 | * this function. |
| 285 | 288 | * @param string the ICU data filename |
| 289 | + * @param string $filename |
|
| 286 | 290 | * @return array ICU data |
| 287 | 291 | */ |
| 288 | 292 | protected function &getData($filename) |
@@ -386,6 +390,7 @@ discard block |
||
| 386 | 390 | /** |
| 387 | 391 | * Set the date time format information. |
| 388 | 392 | * @param DateTimeFormatInfo the new date time format info. |
| 393 | + * @param DateTimeFormatInfo $dateTimeFormat |
|
| 389 | 394 | */ |
| 390 | 395 | function setDateTimeFormat($dateTimeFormat) |
| 391 | 396 | { |
@@ -493,6 +498,7 @@ discard block |
||
| 493 | 498 | /** |
| 494 | 499 | * Set the number format information. |
| 495 | 500 | * @param NumberFormatInfo the new number format info. |
| 501 | + * @param NumberFormatInfo $numberFormat |
|
| 496 | 502 | */ |
| 497 | 503 | function setNumberFormat($numberFormat) |
| 498 | 504 | { |
@@ -199,9 +199,9 @@ |
||
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
| 202 | - * Gets the CultureInfo that for this culture string |
|
| 203 | - * @return CultureInfo invariant culture info is "en". |
|
| 204 | - */ |
|
| 202 | + * Gets the CultureInfo that for this culture string |
|
| 203 | + * @return CultureInfo invariant culture info is "en". |
|
| 204 | + */ |
|
| 205 | 205 | public static function getInstance($culture) |
| 206 | 206 | { |
| 207 | 207 | static $instances = array(); |
@@ -51,13 +51,13 @@ discard block |
||
| 51 | 51 | * ICU data filename extension. |
| 52 | 52 | * @var string |
| 53 | 53 | */ |
| 54 | - private $dataFileExt = '.dat'; |
|
| 54 | + private $dataFileExt='.dat'; |
|
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * The ICU data array. |
| 58 | 58 | * @var array |
| 59 | 59 | */ |
| 60 | - private $data = array(); |
|
| 60 | + private $data=array(); |
|
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * The current culture. |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * A list of ICU date files loaded. |
| 76 | 76 | * @var array |
| 77 | 77 | */ |
| 78 | - private $dataFiles = array(); |
|
| 78 | + private $dataFiles=array(); |
|
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | 81 | * The current date time format info. |
@@ -93,28 +93,28 @@ discard block |
||
| 93 | 93 | * A list of properties that are accessable/writable. |
| 94 | 94 | * @var array |
| 95 | 95 | */ |
| 96 | - protected $properties = array(); |
|
| 96 | + protected $properties=array(); |
|
| 97 | 97 | |
| 98 | 98 | /** |
| 99 | 99 | * Culture type, all. |
| 100 | 100 | * @see getCultures() |
| 101 | 101 | * @var int |
| 102 | 102 | */ |
| 103 | - const ALL = 0; |
|
| 103 | + const ALL=0; |
|
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | 106 | * Culture type, neutral. |
| 107 | 107 | * @see getCultures() |
| 108 | 108 | * @var int |
| 109 | 109 | */ |
| 110 | - const NEUTRAL = 1; |
|
| 110 | + const NEUTRAL=1; |
|
| 111 | 111 | |
| 112 | 112 | /** |
| 113 | 113 | * Culture type, specific. |
| 114 | 114 | * @see getCultures() |
| 115 | 115 | * @var int |
| 116 | 116 | */ |
| 117 | - const SPECIFIC = 2; |
|
| 117 | + const SPECIFIC=2; |
|
| 118 | 118 | |
| 119 | 119 | /** |
| 120 | 120 | * Display the culture name. |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | function __get($name) |
| 136 | 136 | { |
| 137 | - $getProperty = 'get'.$name; |
|
| 137 | + $getProperty='get'.$name; |
|
| 138 | 138 | if(in_array($getProperty, $this->properties)) |
| 139 | 139 | return $this->$getProperty(); |
| 140 | 140 | else |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | function __set($name, $value) |
| 149 | 149 | { |
| 150 | - $setProperty = 'set'.$name; |
|
| 150 | + $setProperty='set'.$name; |
|
| 151 | 151 | if(in_array($setProperty, $this->properties)) |
| 152 | 152 | $this->$setProperty($value); |
| 153 | 153 | else |
@@ -165,13 +165,13 @@ discard block |
||
| 165 | 165 | */ |
| 166 | 166 | function __construct($culture='en') |
| 167 | 167 | { |
| 168 | - $this->properties = get_class_methods($this); |
|
| 168 | + $this->properties=get_class_methods($this); |
|
| 169 | 169 | |
| 170 | 170 | if(empty($culture)) |
| 171 | - $culture = 'en'; |
|
| 171 | + $culture='en'; |
|
| 172 | 172 | |
| 173 | - $this->dataDir = $this->dataDir(); |
|
| 174 | - $this->dataFileExt = $this->fileExt(); |
|
| 173 | + $this->dataDir=$this->dataDir(); |
|
| 174 | + $this->dataFileExt=$this->fileExt(); |
|
| 175 | 175 | |
| 176 | 176 | $this->setCulture($culture); |
| 177 | 177 | |
@@ -204,9 +204,9 @@ discard block |
||
| 204 | 204 | */ |
| 205 | 205 | public static function getInstance($culture) |
| 206 | 206 | { |
| 207 | - static $instances = array(); |
|
| 207 | + static $instances=array(); |
|
| 208 | 208 | if(!isset($instances[$culture])) |
| 209 | - $instances[$culture] = new CultureInfo($culture); |
|
| 209 | + $instances[$culture]=new CultureInfo($culture); |
|
| 210 | 210 | return $instances[$culture]; |
| 211 | 211 | } |
| 212 | 212 | |
@@ -233,11 +233,11 @@ discard block |
||
| 233 | 233 | { |
| 234 | 234 | if(!empty($culture)) |
| 235 | 235 | { |
| 236 | - if (!preg_match('/^[_\\w]+$/', $culture)) |
|
| 237 | - throw new Exception('Invalid culture supplied: ' . $culture); |
|
| 236 | + if(!preg_match('/^[_\\w]+$/', $culture)) |
|
| 237 | + throw new Exception('Invalid culture supplied: '.$culture); |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - $this->culture = $culture; |
|
| 240 | + $this->culture=$culture; |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | /** |
@@ -246,30 +246,30 @@ discard block |
||
| 246 | 246 | */ |
| 247 | 247 | protected function loadCultureData($culture) |
| 248 | 248 | { |
| 249 | - $file_parts = explode('_',$culture); |
|
| 250 | - $current_part = $file_parts[0]; |
|
| 249 | + $file_parts=explode('_', $culture); |
|
| 250 | + $current_part=$file_parts[0]; |
|
| 251 | 251 | |
| 252 | - $files = array($current_part); |
|
| 252 | + $files=array($current_part); |
|
| 253 | 253 | |
| 254 | - for($i = 1, $k = count($file_parts); $i < $k; ++$i) |
|
| 254 | + for($i=1, $k=count($file_parts); $i < $k; ++$i) |
|
| 255 | 255 | { |
| 256 | - $current_part .= '_'.$file_parts[$i]; |
|
| 257 | - $files[] = $current_part; |
|
| 256 | + $current_part.='_'.$file_parts[$i]; |
|
| 257 | + $files[]=$current_part; |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | foreach($files as $file) |
| 261 | 261 | { |
| 262 | - $filename = $this->dataDir.$file.$this->dataFileExt; |
|
| 262 | + $filename=$this->dataDir.$file.$this->dataFileExt; |
|
| 263 | 263 | |
| 264 | - if(is_file($filename) == false) |
|
| 264 | + if(is_file($filename)==false) |
|
| 265 | 265 | throw new Exception('Data file for "'.$file.'" was not found.'); |
| 266 | 266 | |
| 267 | - if(in_array($filename, $this->dataFiles) === false) |
|
| 267 | + if(in_array($filename, $this->dataFiles)===false) |
|
| 268 | 268 | { |
| 269 | 269 | array_unshift($this->dataFiles, $file); |
| 270 | 270 | |
| 271 | - $data = &$this->getData($filename); |
|
| 272 | - $this->data[$file] = &$data; |
|
| 271 | + $data=&$this->getData($filename); |
|
| 272 | + $this->data[$file]=&$data; |
|
| 273 | 273 | |
| 274 | 274 | if(isset($data['__ALIAS'])) |
| 275 | 275 | $this->loadCultureData($data['__ALIAS'][0]); |
@@ -287,13 +287,13 @@ discard block |
||
| 287 | 287 | */ |
| 288 | 288 | protected function &getData($filename) |
| 289 | 289 | { |
| 290 | - static $data = array(); |
|
| 291 | - static $files = array(); |
|
| 290 | + static $data=array(); |
|
| 291 | + static $files=array(); |
|
| 292 | 292 | |
| 293 | 293 | if(!in_array($filename, $files)) |
| 294 | 294 | { |
| 295 | - $data[$filename] = unserialize(file_get_contents($filename)); |
|
| 296 | - $files[] = $filename; |
|
| 295 | + $data[$filename]=unserialize(file_get_contents($filename)); |
|
| 296 | + $files[]=$filename; |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | return $data[$filename]; |
@@ -315,15 +315,15 @@ discard block |
||
| 315 | 315 | */ |
| 316 | 316 | protected function findInfo($path='/', $merge=false) |
| 317 | 317 | { |
| 318 | - $result = array(); |
|
| 318 | + $result=array(); |
|
| 319 | 319 | foreach($this->dataFiles as $section) |
| 320 | 320 | { |
| 321 | - $info = $this->searchArray($this->data[$section], $path); |
|
| 321 | + $info=$this->searchArray($this->data[$section], $path); |
|
| 322 | 322 | |
| 323 | 323 | if($info) |
| 324 | 324 | { |
| 325 | 325 | if($merge) |
| 326 | - $result = array_merge($info,$result); |
|
| 326 | + $result=array_merge($info, $result); |
|
| 327 | 327 | else |
| 328 | 328 | return $info; |
| 329 | 329 | } |
@@ -342,16 +342,16 @@ discard block |
||
| 342 | 342 | */ |
| 343 | 343 | private function searchArray($info, $path='/') |
| 344 | 344 | { |
| 345 | - $index = explode('/',$path); |
|
| 345 | + $index=explode('/', $path); |
|
| 346 | 346 | |
| 347 | - $array = $info; |
|
| 347 | + $array=$info; |
|
| 348 | 348 | |
| 349 | - for($i = 0, $k = count($index); $i < $k; ++$i) |
|
| 349 | + for($i=0, $k=count($index); $i < $k; ++$i) |
|
| 350 | 350 | { |
| 351 | - $value = $index[$i]; |
|
| 352 | - if($i < $k-1 && isset($array[$value])) |
|
| 353 | - $array = $array[$value]; |
|
| 354 | - else if ($i == $k-1 && isset($array[$value])) |
|
| 351 | + $value=$index[$i]; |
|
| 352 | + if($i < $k - 1 && isset($array[$value])) |
|
| 353 | + $array=$array[$value]; |
|
| 354 | + else if($i==$k - 1 && isset($array[$value])) |
|
| 355 | 355 | return $array[$value]; |
| 356 | 356 | } |
| 357 | 357 | } |
@@ -373,10 +373,10 @@ discard block |
||
| 373 | 373 | */ |
| 374 | 374 | function getDateTimeFormat() |
| 375 | 375 | { |
| 376 | - if($this->dateTimeFormat === null) |
|
| 376 | + if($this->dateTimeFormat===null) |
|
| 377 | 377 | { |
| 378 | - $calendar = $this->getCalendar(); |
|
| 379 | - $info = $this->findInfo("calendar/{$calendar}", true); |
|
| 378 | + $calendar=$this->getCalendar(); |
|
| 379 | + $info=$this->findInfo("calendar/{$calendar}", true); |
|
| 380 | 380 | $this->setDateTimeFormat(new DateTimeFormatInfo($info)); |
| 381 | 381 | } |
| 382 | 382 | |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | */ |
| 390 | 390 | function setDateTimeFormat($dateTimeFormat) |
| 391 | 391 | { |
| 392 | - $this->dateTimeFormat = $dateTimeFormat; |
|
| 392 | + $this->dateTimeFormat=$dateTimeFormat; |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | /** |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | */ |
| 399 | 399 | function getCalendar() |
| 400 | 400 | { |
| 401 | - $info = $this->findInfo('calendar/default'); |
|
| 401 | + $info=$this->findInfo('calendar/default'); |
|
| 402 | 402 | return $info[0]; |
| 403 | 403 | } |
| 404 | 404 | |
@@ -410,10 +410,10 @@ discard block |
||
| 410 | 410 | */ |
| 411 | 411 | function getNativeName() |
| 412 | 412 | { |
| 413 | - $lang = substr($this->culture,0,2); |
|
| 414 | - $reg = substr($this->culture,3,2); |
|
| 415 | - $language = $this->findInfo("Languages/{$lang}"); |
|
| 416 | - $region = $this->findInfo("Countries/{$reg}"); |
|
| 413 | + $lang=substr($this->culture, 0, 2); |
|
| 414 | + $reg=substr($this->culture, 3, 2); |
|
| 415 | + $language=$this->findInfo("Languages/{$lang}"); |
|
| 416 | + $region=$this->findInfo("Countries/{$reg}"); |
|
| 417 | 417 | if($region) |
| 418 | 418 | return $language[0].' ('.$region[0].')'; |
| 419 | 419 | else |
@@ -428,15 +428,15 @@ discard block |
||
| 428 | 428 | */ |
| 429 | 429 | function getEnglishName() |
| 430 | 430 | { |
| 431 | - $lang = substr($this->culture,0,2); |
|
| 432 | - $reg = substr($this->culture,3,2); |
|
| 433 | - $culture = $this->getInvariantCulture(); |
|
| 431 | + $lang=substr($this->culture, 0, 2); |
|
| 432 | + $reg=substr($this->culture, 3, 2); |
|
| 433 | + $culture=$this->getInvariantCulture(); |
|
| 434 | 434 | |
| 435 | - $language = $culture->findInfo("Languages/{$lang}"); |
|
| 436 | - if(count($language) == 0) |
|
| 435 | + $language=$culture->findInfo("Languages/{$lang}"); |
|
| 436 | + if(count($language)==0) |
|
| 437 | 437 | return $this->culture; |
| 438 | 438 | |
| 439 | - $region = $culture->findInfo("Countries/{$reg}"); |
|
| 439 | + $region=$culture->findInfo("Countries/{$reg}"); |
|
| 440 | 440 | if($region) |
| 441 | 441 | return $language[0].' ('.$region[0].')'; |
| 442 | 442 | else |
@@ -453,8 +453,8 @@ discard block |
||
| 453 | 453 | static function getInvariantCulture() |
| 454 | 454 | { |
| 455 | 455 | static $invariant; |
| 456 | - if($invariant === null) |
|
| 457 | - $invariant = new CultureInfo(); |
|
| 456 | + if($invariant===null) |
|
| 457 | + $invariant=new CultureInfo(); |
|
| 458 | 458 | return $invariant; |
| 459 | 459 | } |
| 460 | 460 | |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | */ |
| 467 | 467 | function getIsNeutralCulture() |
| 468 | 468 | { |
| 469 | - return strlen($this->culture) == 2; |
|
| 469 | + return strlen($this->culture)==2; |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | /** |
@@ -476,12 +476,12 @@ discard block |
||
| 476 | 476 | */ |
| 477 | 477 | function getNumberFormat() |
| 478 | 478 | { |
| 479 | - if($this->numberFormat === null) |
|
| 479 | + if($this->numberFormat===null) |
|
| 480 | 480 | { |
| 481 | - $elements = $this->findInfo('NumberElements'); |
|
| 482 | - $patterns = $this->findInfo('NumberPatterns'); |
|
| 483 | - $currencies = $this->getCurrencies(); |
|
| 484 | - $data = array( 'NumberElements'=>$elements, |
|
| 481 | + $elements=$this->findInfo('NumberElements'); |
|
| 482 | + $patterns=$this->findInfo('NumberPatterns'); |
|
| 483 | + $currencies=$this->getCurrencies(); |
|
| 484 | + $data=array('NumberElements'=>$elements, |
|
| 485 | 485 | 'NumberPatterns'=>$patterns, |
| 486 | 486 | 'Currencies' => $currencies); |
| 487 | 487 | |
@@ -496,7 +496,7 @@ discard block |
||
| 496 | 496 | */ |
| 497 | 497 | function setNumberFormat($numberFormat) |
| 498 | 498 | { |
| 499 | - $this->numberFormat = $numberFormat; |
|
| 499 | + $this->numberFormat=$numberFormat; |
|
| 500 | 500 | } |
| 501 | 501 | |
| 502 | 502 | /** |
@@ -506,10 +506,10 @@ discard block |
||
| 506 | 506 | */ |
| 507 | 507 | function getParent() |
| 508 | 508 | { |
| 509 | - if(strlen($this->culture) == 2) |
|
| 509 | + if(strlen($this->culture)==2) |
|
| 510 | 510 | return $this->getInvariantCulture(); |
| 511 | 511 | |
| 512 | - $lang = substr($this->culture,0,2); |
|
| 512 | + $lang=substr($this->culture, 0, 2); |
|
| 513 | 513 | return new CultureInfo($lang); |
| 514 | 514 | } |
| 515 | 515 | |
@@ -524,24 +524,24 @@ discard block |
||
| 524 | 524 | */ |
| 525 | 525 | static function getCultures($type=CultureInfo::ALL) |
| 526 | 526 | { |
| 527 | - $dataDir = CultureInfo::dataDir(); |
|
| 528 | - $dataExt = CultureInfo::fileExt(); |
|
| 529 | - $dir = dir($dataDir); |
|
| 527 | + $dataDir=CultureInfo::dataDir(); |
|
| 528 | + $dataExt=CultureInfo::fileExt(); |
|
| 529 | + $dir=dir($dataDir); |
|
| 530 | 530 | |
| 531 | - $neutral = array(); |
|
| 532 | - $specific = array(); |
|
| 531 | + $neutral=array(); |
|
| 532 | + $specific=array(); |
|
| 533 | 533 | |
| 534 | - while (false !== ($entry = $dir->read())) |
|
| 534 | + while(false!==($entry=$dir->read())) |
|
| 535 | 535 | { |
| 536 | 536 | if(is_file($dataDir.$entry) |
| 537 | - && substr($entry,-4) == $dataExt |
|
| 538 | - && $entry != 'root'.$dataExt) |
|
| 537 | + && substr($entry, -4)==$dataExt |
|
| 538 | + && $entry!='root'.$dataExt) |
|
| 539 | 539 | { |
| 540 | - $culture = substr($entry,0,-4); |
|
| 541 | - if(strlen($culture) == 2) |
|
| 542 | - $neutral[] = $culture; |
|
| 540 | + $culture=substr($entry, 0, -4); |
|
| 541 | + if(strlen($culture)==2) |
|
| 542 | + $neutral[]=$culture; |
|
| 543 | 543 | else |
| 544 | - $specific[] = $culture; |
|
| 544 | + $specific[]=$culture; |
|
| 545 | 545 | } |
| 546 | 546 | } |
| 547 | 547 | $dir->close(); |
@@ -549,7 +549,7 @@ discard block |
||
| 549 | 549 | switch($type) |
| 550 | 550 | { |
| 551 | 551 | case CultureInfo::ALL : |
| 552 | - $all = array_merge($neutral, $specific); |
|
| 552 | + $all=array_merge($neutral, $specific); |
|
| 553 | 553 | sort($all); |
| 554 | 554 | return $all; |
| 555 | 555 | break; |
@@ -571,12 +571,12 @@ discard block |
||
| 571 | 571 | */ |
| 572 | 572 | private function simplify($array) |
| 573 | 573 | { |
| 574 | - for($i = 0, $k = count($array); $i<$k; ++$i) |
|
| 574 | + for($i=0, $k=count($array); $i < $k; ++$i) |
|
| 575 | 575 | { |
| 576 | - $key = key($array); |
|
| 576 | + $key=key($array); |
|
| 577 | 577 | if(is_array($array[$key]) |
| 578 | - && count($array[$key]) == 1) |
|
| 579 | - $array[$key] = $array[$key][0]; |
|
| 578 | + && count($array[$key])==1) |
|
| 579 | + $array[$key]=$array[$key][0]; |
|
| 580 | 580 | next($array); |
| 581 | 581 | } |
| 582 | 582 | return $array; |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | */ |
| 589 | 589 | function getCountries() |
| 590 | 590 | { |
| 591 | - return $this->simplify($this->findInfo('Countries',true)); |
|
| 591 | + return $this->simplify($this->findInfo('Countries', true)); |
|
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | /** |
@@ -597,7 +597,7 @@ discard block |
||
| 597 | 597 | */ |
| 598 | 598 | function getCurrencies() |
| 599 | 599 | { |
| 600 | - return $this->findInfo('Currencies',true); |
|
| 600 | + return $this->findInfo('Currencies', true); |
|
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | /** |
@@ -606,7 +606,7 @@ discard block |
||
| 606 | 606 | */ |
| 607 | 607 | function getLanguages() |
| 608 | 608 | { |
| 609 | - return $this->simplify($this->findInfo('Languages',true)); |
|
| 609 | + return $this->simplify($this->findInfo('Languages', true)); |
|
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | /** |
@@ -615,7 +615,7 @@ discard block |
||
| 615 | 615 | */ |
| 616 | 616 | function getScripts() |
| 617 | 617 | { |
| 618 | - return $this->simplify($this->findInfo('Scripts',true)); |
|
| 618 | + return $this->simplify($this->findInfo('Scripts', true)); |
|
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | /** |
@@ -624,7 +624,7 @@ discard block |
||
| 624 | 624 | */ |
| 625 | 625 | function getTimeZones() |
| 626 | 626 | { |
| 627 | - return $this->simplify($this->findInfo('zoneStrings',true)); |
|
| 627 | + return $this->simplify($this->findInfo('zoneStrings', true)); |
|
| 628 | 628 | } |
| 629 | 629 | } |
| 630 | 630 | |