@@ -55,6 +55,7 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * @param string a unique identifier for the <parameterMap>. |
| 58 | + * @param string $value |
|
| 58 | 59 | */ |
| 59 | 60 | public function setID($value) |
| 60 | 61 | { |
@@ -62,7 +63,7 @@ discard block |
||
| 62 | 63 | } |
| 63 | 64 | |
| 64 | 65 | /** |
| 65 | - * @return TParameterProperty[] list of properties for the parameter map. |
|
| 66 | + * @return TList list of properties for the parameter map. |
|
| 66 | 67 | */ |
| 67 | 68 | public function getProperties() |
| 68 | 69 | { |
@@ -112,6 +113,7 @@ discard block |
||
| 112 | 113 | /** |
| 113 | 114 | * @param int parameter property index |
| 114 | 115 | * @param TParameterProperty new parameter property. |
| 116 | + * @param integer $index |
|
| 115 | 117 | */ |
| 116 | 118 | public function insertProperty($index, TParameterProperty $property) |
| 117 | 119 | { |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | public function setID($value) |
| 60 | 60 | { |
| 61 | - $this->_ID=$value; |
|
| 61 | + $this->_ID = $value; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -92,9 +92,9 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public function getProperty($index) |
| 94 | 94 | { |
| 95 | - if(is_string($index)) |
|
| 95 | + if (is_string($index)) |
|
| 96 | 96 | return $this->_propertyMap->itemAt($index); |
| 97 | - else if(is_int($index)) |
|
| 97 | + else if (is_int($index)) |
|
| 98 | 98 | return $this->_properties->itemAt($index); |
| 99 | 99 | else |
| 100 | 100 | throw new TSqlMapException('sqlmap_index_must_be_string_or_int', $index); |
@@ -136,14 +136,14 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | public function getPropertyValue($registry, $property, $parameterValue) |
| 138 | 138 | { |
| 139 | - $value = $this->getObjectValue($parameterValue,$property); |
|
| 139 | + $value = $this->getObjectValue($parameterValue, $property); |
|
| 140 | 140 | |
| 141 | - if(($handler=$this->createTypeHandler($property, $registry))!==null) |
|
| 141 | + if (($handler = $this->createTypeHandler($property, $registry)) !== null) |
|
| 142 | 142 | $value = $handler->getParameter($value); |
| 143 | 143 | |
| 144 | - $value = $this->nullifyDefaultValue($property,$value); |
|
| 144 | + $value = $this->nullifyDefaultValue($property, $value); |
|
| 145 | 145 | |
| 146 | - if(($type = $property->getType())!==null) |
|
| 146 | + if (($type = $property->getType()) !== null) |
|
| 147 | 147 | $value = $registry->convertToType($type, $value); |
| 148 | 148 | |
| 149 | 149 | return $value; |
@@ -158,9 +158,9 @@ discard block |
||
| 158 | 158 | */ |
| 159 | 159 | protected function createTypeHandler($property, $registry) |
| 160 | 160 | { |
| 161 | - $type=$property->getTypeHandler() ? $property->getTypeHandler() : $property->getType(); |
|
| 162 | - $handler=$registry->getTypeHandler($type); |
|
| 163 | - if($handler===null && $property->getTypeHandler()) |
|
| 161 | + $type = $property->getTypeHandler() ? $property->getTypeHandler() : $property->getType(); |
|
| 162 | + $handler = $registry->getTypeHandler($type); |
|
| 163 | + if ($handler === null && $property->getTypeHandler()) |
|
| 164 | 164 | $handler = Prado::createComponent($type); |
| 165 | 165 | return $handler; |
| 166 | 166 | } |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | * @return mixed property value. |
| 173 | 173 | * @throws TSqlMapException if property access is invalid. |
| 174 | 174 | */ |
| 175 | - protected function getObjectValue($object,$property) |
|
| 175 | + protected function getObjectValue($object, $property) |
|
| 176 | 176 | { |
| 177 | 177 | try |
| 178 | 178 | { |
@@ -196,11 +196,11 @@ discard block |
||
| 196 | 196 | * @param mixed current property value |
| 197 | 197 | * @return mixed null if NullValue matches currrent value. |
| 198 | 198 | */ |
| 199 | - protected function nullifyDefaultValue($property,$value) |
|
| 199 | + protected function nullifyDefaultValue($property, $value) |
|
| 200 | 200 | { |
| 201 | - if(($nullValue = $property->getNullValue())!==null) |
|
| 201 | + if (($nullValue = $property->getNullValue()) !== null) |
|
| 202 | 202 | { |
| 203 | - if($nullValue === $value) |
|
| 203 | + if ($nullValue === $value) |
|
| 204 | 204 | $value = null; |
| 205 | 205 | } |
| 206 | 206 | return $value; |
@@ -92,12 +92,13 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public function getProperty($index) |
| 94 | 94 | { |
| 95 | - if(is_string($index)) |
|
| 96 | - return $this->_propertyMap->itemAt($index); |
|
| 97 | - else if(is_int($index)) |
|
| 98 | - return $this->_properties->itemAt($index); |
|
| 99 | - else |
|
| 100 | - throw new TSqlMapException('sqlmap_index_must_be_string_or_int', $index); |
|
| 95 | + if(is_string($index)) { |
|
| 96 | + return $this->_propertyMap->itemAt($index); |
|
| 97 | + } else if(is_int($index)) { |
|
| 98 | + return $this->_properties->itemAt($index); |
|
| 99 | + } else { |
|
| 100 | + throw new TSqlMapException('sqlmap_index_must_be_string_or_int', $index); |
|
| 101 | + } |
|
| 101 | 102 | } |
| 102 | 103 | |
| 103 | 104 | /** |
@@ -138,13 +139,15 @@ discard block |
||
| 138 | 139 | { |
| 139 | 140 | $value = $this->getObjectValue($parameterValue,$property); |
| 140 | 141 | |
| 141 | - if(($handler=$this->createTypeHandler($property, $registry))!==null) |
|
| 142 | - $value = $handler->getParameter($value); |
|
| 142 | + if(($handler=$this->createTypeHandler($property, $registry))!==null) { |
|
| 143 | + $value = $handler->getParameter($value); |
|
| 144 | + } |
|
| 143 | 145 | |
| 144 | 146 | $value = $this->nullifyDefaultValue($property,$value); |
| 145 | 147 | |
| 146 | - if(($type = $property->getType())!==null) |
|
| 147 | - $value = $registry->convertToType($type, $value); |
|
| 148 | + if(($type = $property->getType())!==null) { |
|
| 149 | + $value = $registry->convertToType($type, $value); |
|
| 150 | + } |
|
| 148 | 151 | |
| 149 | 152 | return $value; |
| 150 | 153 | } |
@@ -160,8 +163,9 @@ discard block |
||
| 160 | 163 | { |
| 161 | 164 | $type=$property->getTypeHandler() ? $property->getTypeHandler() : $property->getType(); |
| 162 | 165 | $handler=$registry->getTypeHandler($type); |
| 163 | - if($handler===null && $property->getTypeHandler()) |
|
| 164 | - $handler = Prado::createComponent($type); |
|
| 166 | + if($handler===null && $property->getTypeHandler()) { |
|
| 167 | + $handler = Prado::createComponent($type); |
|
| 168 | + } |
|
| 165 | 169 | return $handler; |
| 166 | 170 | } |
| 167 | 171 | |
@@ -177,8 +181,7 @@ discard block |
||
| 177 | 181 | try |
| 178 | 182 | { |
| 179 | 183 | return TPropertyAccess::get($object, $property->getProperty()); |
| 180 | - } |
|
| 181 | - catch (TInvalidPropertyException $e) |
|
| 184 | + } catch (TInvalidPropertyException $e) |
|
| 182 | 185 | { |
| 183 | 186 | throw new TSqlMapException( |
| 184 | 187 | 'sqlmap_unable_to_get_property_for_parameter', |
@@ -200,8 +203,9 @@ discard block |
||
| 200 | 203 | { |
| 201 | 204 | if(($nullValue = $property->getNullValue())!==null) |
| 202 | 205 | { |
| 203 | - if($nullValue === $value) |
|
| 204 | - $value = null; |
|
| 206 | + if($nullValue === $value) { |
|
| 207 | + $value = null; |
|
| 208 | + } |
|
| 205 | 209 | } |
| 206 | 210 | return $value; |
| 207 | 211 | } |
@@ -103,6 +103,7 @@ discard block |
||
| 103 | 103 | /** |
| 104 | 104 | * @param string name of the column in the result set from which the value |
| 105 | 105 | * will be used to populate the property. |
| 106 | + * @param string $value |
|
| 106 | 107 | */ |
| 107 | 108 | public function setColumn($value) |
| 108 | 109 | { |
@@ -121,6 +122,7 @@ discard block |
||
| 121 | 122 | /** |
| 122 | 123 | * @param int index of the column in the ResultSet from which the value will |
| 123 | 124 | * be used to populate the object property |
| 125 | + * @param integer $value |
|
| 124 | 126 | */ |
| 125 | 127 | public function setColumnIndex($value) |
| 126 | 128 | { |
@@ -185,6 +187,7 @@ discard block |
||
| 185 | 187 | |
| 186 | 188 | /** |
| 187 | 189 | * @param string custom type handler class name (may use namespace). |
| 190 | + * @param string $value |
|
| 188 | 191 | */ |
| 189 | 192 | public function setTypeHandler($value) |
| 190 | 193 | { |
@@ -36,15 +36,15 @@ discard block |
||
| 36 | 36 | private $_nullValue; |
| 37 | 37 | private $_propertyName; |
| 38 | 38 | private $_columnName; |
| 39 | - private $_columnIndex=-1; |
|
| 39 | + private $_columnIndex = -1; |
|
| 40 | 40 | private $_nestedResultMapName; |
| 41 | 41 | private $_nestedResultMap; |
| 42 | 42 | private $_valueType; |
| 43 | 43 | private $_typeHandler; |
| 44 | - private $_isLazyLoad=false; |
|
| 44 | + private $_isLazyLoad = false; |
|
| 45 | 45 | private $_select; |
| 46 | 46 | |
| 47 | - private $_hostResultMapID='inplicit internal mapping'; |
|
| 47 | + private $_hostResultMapID = 'inplicit internal mapping'; |
|
| 48 | 48 | |
| 49 | 49 | const LIST_TYPE = 0; |
| 50 | 50 | const ARRAY_TYPE = 1; |
@@ -53,9 +53,9 @@ discard block |
||
| 53 | 53 | * Gets the containing result map ID. |
| 54 | 54 | * @param TResultMap containing result map. |
| 55 | 55 | */ |
| 56 | - public function __construct($resultMap=null) |
|
| 56 | + public function __construct($resultMap = null) |
|
| 57 | 57 | { |
| 58 | - if($resultMap instanceof TResultMap) |
|
| 58 | + if ($resultMap instanceof TResultMap) |
|
| 59 | 59 | $this->_hostResultMapID = $resultMap->getID(); |
| 60 | 60 | } |
| 61 | 61 | |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | */ |
| 223 | 223 | public function setLazyLoad($value) |
| 224 | 224 | { |
| 225 | - $this->_isLazyLoad = TPropertyValue::ensureBoolean($value,false); |
|
| 225 | + $this->_isLazyLoad = TPropertyValue::ensureBoolean($value, false); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | /** |
@@ -231,17 +231,17 @@ discard block |
||
| 231 | 231 | * @param array result row |
| 232 | 232 | * @return mixed property value. |
| 233 | 233 | */ |
| 234 | - public function getPropertyValue($registry,$row) |
|
| 234 | + public function getPropertyValue($registry, $row) |
|
| 235 | 235 | { |
| 236 | 236 | $value = null; |
| 237 | 237 | $index = $this->getColumnIndex(); |
| 238 | 238 | $name = $this->getColumn(); |
| 239 | - if($index > 0 && isset($row[$index])) |
|
| 240 | - $value = $this->getTypedValue($registry,$row[$index]); |
|
| 241 | - else if(isset($row[$name])) |
|
| 242 | - $value = $this->getTypedValue($registry,$row[$name]); |
|
| 243 | - if(($value===null) && ($this->getNullValue()!==null)) |
|
| 244 | - $value = $this->getTypedValue($registry,$this->getNullValue()); |
|
| 239 | + if ($index > 0 && isset($row[$index])) |
|
| 240 | + $value = $this->getTypedValue($registry, $row[$index]); |
|
| 241 | + else if (isset($row[$name])) |
|
| 242 | + $value = $this->getTypedValue($registry, $row[$name]); |
|
| 243 | + if (($value === null) && ($this->getNullValue() !== null)) |
|
| 244 | + $value = $this->getTypedValue($registry, $this->getNullValue()); |
|
| 245 | 245 | return $value; |
| 246 | 246 | } |
| 247 | 247 | |
@@ -250,9 +250,9 @@ discard block |
||
| 250 | 250 | * @param mixed raw property value |
| 251 | 251 | * @return mixed property value casted to specific type. |
| 252 | 252 | */ |
| 253 | - protected function getTypedValue($registry,$value) |
|
| 253 | + protected function getTypedValue($registry, $value) |
|
| 254 | 254 | { |
| 255 | - if(($handler = $this->createTypeHandler($registry))!==null) |
|
| 255 | + if (($handler = $this->createTypeHandler($registry)) !== null) |
|
| 256 | 256 | return $handler->getResult($value); |
| 257 | 257 | else |
| 258 | 258 | return $registry->convertToType($this->getType(), $value); |
@@ -265,9 +265,9 @@ discard block |
||
| 265 | 265 | */ |
| 266 | 266 | protected function createTypeHandler($registry) |
| 267 | 267 | { |
| 268 | - $type=$this->getTypeHandler() ? $this->getTypeHandler() : $this->getType(); |
|
| 269 | - $handler=$registry->getTypeHandler($type); |
|
| 270 | - if($handler===null && $this->getTypeHandler()) |
|
| 268 | + $type = $this->getTypeHandler() ? $this->getTypeHandler() : $this->getType(); |
|
| 269 | + $handler = $registry->getTypeHandler($type); |
|
| 270 | + if ($handler === null && $this->getTypeHandler()) |
|
| 271 | 271 | $handler = Prado::createComponent($type); |
| 272 | 272 | return $handler; |
| 273 | 273 | } |
@@ -278,17 +278,17 @@ discard block |
||
| 278 | 278 | */ |
| 279 | 279 | protected function getPropertyValueType() |
| 280 | 280 | { |
| 281 | - if(class_exists($type = $this->getType(), false)) //NO force autoloading |
|
| 281 | + if (class_exists($type = $this->getType(), false)) //NO force autoloading |
|
| 282 | 282 | { |
| 283 | - if($type==='TList') |
|
| 283 | + if ($type === 'TList') |
|
| 284 | 284 | return self::LIST_TYPE; |
| 285 | 285 | $class = new ReflectionClass($type); |
| 286 | - if($class->isSubclassOf('TList')) |
|
| 286 | + if ($class->isSubclassOf('TList')) |
|
| 287 | 287 | return self::LIST_TYPE; |
| 288 | - if($class->implementsInterface('ArrayAccess')) |
|
| 288 | + if ($class->implementsInterface('ArrayAccess')) |
|
| 289 | 289 | return self::ARRAY_TYPE; |
| 290 | 290 | } |
| 291 | - if(strtolower($type) == 'array') |
|
| 291 | + if (strtolower($type) == 'array') |
|
| 292 | 292 | return self::ARRAY_TYPE; |
| 293 | 293 | } |
| 294 | 294 | |
@@ -300,8 +300,8 @@ discard block |
||
| 300 | 300 | */ |
| 301 | 301 | public function instanceOfListType($target) |
| 302 | 302 | { |
| 303 | - if($this->getType()===null) |
|
| 304 | - return TPropertyAccess::get($target,$this->getProperty()) instanceof TList; |
|
| 303 | + if ($this->getType() === null) |
|
| 304 | + return TPropertyAccess::get($target, $this->getProperty()) instanceof TList; |
|
| 305 | 305 | return $this->getPropertyValueType() == self::LIST_TYPE; |
| 306 | 306 | } |
| 307 | 307 | |
@@ -313,10 +313,10 @@ discard block |
||
| 313 | 313 | */ |
| 314 | 314 | public function instanceOfArrayType($target) |
| 315 | 315 | { |
| 316 | - if($this->getType()===null) |
|
| 316 | + if ($this->getType() === null) |
|
| 317 | 317 | { |
| 318 | - $prop = TPropertyAccess::get($target,$this->getProperty()); |
|
| 319 | - if(is_object($prop)) |
|
| 318 | + $prop = TPropertyAccess::get($target, $this->getProperty()); |
|
| 319 | + if (is_object($prop)) |
|
| 320 | 320 | return $prop instanceof ArrayAccess; |
| 321 | 321 | return is_array($prop); |
| 322 | 322 | } |
@@ -326,17 +326,17 @@ discard block |
||
| 326 | 326 | public function __sleep() |
| 327 | 327 | { |
| 328 | 328 | $exprops = array(); $cn = 'TResultProperty'; |
| 329 | - if ($this->_nullValue===null) $exprops[] = "\0$cn\0_nullValue"; |
|
| 330 | - if ($this->_propertyName===null) $exprops[] = "\0$cn\0_propertyNama"; |
|
| 331 | - if ($this->_columnName===null) $exprops[] = "\0$cn\0_columnName"; |
|
| 332 | - if ($this->_columnIndex==-1) $exprops[] = "\0$cn\0_columnIndex"; |
|
| 333 | - if ($this->_nestedResultMapName===null) $exprops[] = "\0$cn\0_nestedResultMapName"; |
|
| 334 | - if ($this->_nestedResultMap===null) $exprops[] = "\0$cn\0_nestedResultMap"; |
|
| 335 | - if ($this->_valueType===null) $exprops[] = "\0$cn\0_valueType"; |
|
| 336 | - if ($this->_typeHandler===null) $exprops[] = "\0$cn\0_typeHandler"; |
|
| 337 | - if ($this->_isLazyLoad===false) $exprops[] = "\0$cn\0_isLazyLoad"; |
|
| 338 | - if ($this->_select===null) $exprops[] = "\0$cn\0_select"; |
|
| 339 | - return array_diff(parent::__sleep(),$exprops); |
|
| 329 | + if ($this->_nullValue === null) $exprops[] = "\0$cn\0_nullValue"; |
|
| 330 | + if ($this->_propertyName === null) $exprops[] = "\0$cn\0_propertyNama"; |
|
| 331 | + if ($this->_columnName === null) $exprops[] = "\0$cn\0_columnName"; |
|
| 332 | + if ($this->_columnIndex == -1) $exprops[] = "\0$cn\0_columnIndex"; |
|
| 333 | + if ($this->_nestedResultMapName === null) $exprops[] = "\0$cn\0_nestedResultMapName"; |
|
| 334 | + if ($this->_nestedResultMap === null) $exprops[] = "\0$cn\0_nestedResultMap"; |
|
| 335 | + if ($this->_valueType === null) $exprops[] = "\0$cn\0_valueType"; |
|
| 336 | + if ($this->_typeHandler === null) $exprops[] = "\0$cn\0_typeHandler"; |
|
| 337 | + if ($this->_isLazyLoad === false) $exprops[] = "\0$cn\0_isLazyLoad"; |
|
| 338 | + if ($this->_select === null) $exprops[] = "\0$cn\0_select"; |
|
| 339 | + return array_diff(parent::__sleep(), $exprops); |
|
| 340 | 340 | } |
| 341 | 341 | } |
| 342 | 342 | |
@@ -55,8 +55,9 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | public function __construct($resultMap=null) |
| 57 | 57 | { |
| 58 | - if($resultMap instanceof TResultMap) |
|
| 59 | - $this->_hostResultMapID = $resultMap->getID(); |
|
| 58 | + if($resultMap instanceof TResultMap) { |
|
| 59 | + $this->_hostResultMapID = $resultMap->getID(); |
|
| 60 | + } |
|
| 60 | 61 | } |
| 61 | 62 | |
| 62 | 63 | /** |
@@ -236,12 +237,14 @@ discard block |
||
| 236 | 237 | $value = null; |
| 237 | 238 | $index = $this->getColumnIndex(); |
| 238 | 239 | $name = $this->getColumn(); |
| 239 | - if($index > 0 && isset($row[$index])) |
|
| 240 | - $value = $this->getTypedValue($registry,$row[$index]); |
|
| 241 | - else if(isset($row[$name])) |
|
| 242 | - $value = $this->getTypedValue($registry,$row[$name]); |
|
| 243 | - if(($value===null) && ($this->getNullValue()!==null)) |
|
| 244 | - $value = $this->getTypedValue($registry,$this->getNullValue()); |
|
| 240 | + if($index > 0 && isset($row[$index])) { |
|
| 241 | + $value = $this->getTypedValue($registry,$row[$index]); |
|
| 242 | + } else if(isset($row[$name])) { |
|
| 243 | + $value = $this->getTypedValue($registry,$row[$name]); |
|
| 244 | + } |
|
| 245 | + if(($value===null) && ($this->getNullValue()!==null)) { |
|
| 246 | + $value = $this->getTypedValue($registry,$this->getNullValue()); |
|
| 247 | + } |
|
| 245 | 248 | return $value; |
| 246 | 249 | } |
| 247 | 250 | |
@@ -252,10 +255,11 @@ discard block |
||
| 252 | 255 | */ |
| 253 | 256 | protected function getTypedValue($registry,$value) |
| 254 | 257 | { |
| 255 | - if(($handler = $this->createTypeHandler($registry))!==null) |
|
| 256 | - return $handler->getResult($value); |
|
| 257 | - else |
|
| 258 | - return $registry->convertToType($this->getType(), $value); |
|
| 258 | + if(($handler = $this->createTypeHandler($registry))!==null) { |
|
| 259 | + return $handler->getResult($value); |
|
| 260 | + } else { |
|
| 261 | + return $registry->convertToType($this->getType(), $value); |
|
| 262 | + } |
|
| 259 | 263 | } |
| 260 | 264 | |
| 261 | 265 | /** |
@@ -267,8 +271,9 @@ discard block |
||
| 267 | 271 | { |
| 268 | 272 | $type=$this->getTypeHandler() ? $this->getTypeHandler() : $this->getType(); |
| 269 | 273 | $handler=$registry->getTypeHandler($type); |
| 270 | - if($handler===null && $this->getTypeHandler()) |
|
| 271 | - $handler = Prado::createComponent($type); |
|
| 274 | + if($handler===null && $this->getTypeHandler()) { |
|
| 275 | + $handler = Prado::createComponent($type); |
|
| 276 | + } |
|
| 272 | 277 | return $handler; |
| 273 | 278 | } |
| 274 | 279 | |
@@ -278,18 +283,23 @@ discard block |
||
| 278 | 283 | */ |
| 279 | 284 | protected function getPropertyValueType() |
| 280 | 285 | { |
| 281 | - if(class_exists($type = $this->getType(), false)) //NO force autoloading |
|
| 286 | + if(class_exists($type = $this->getType(), false)) { |
|
| 287 | + //NO force autoloading |
|
| 282 | 288 | { |
| 283 | 289 | if($type==='TList') |
| 284 | 290 | return self::LIST_TYPE; |
| 291 | + } |
|
| 285 | 292 | $class = new ReflectionClass($type); |
| 286 | - if($class->isSubclassOf('TList')) |
|
| 287 | - return self::LIST_TYPE; |
|
| 288 | - if($class->implementsInterface('ArrayAccess')) |
|
| 289 | - return self::ARRAY_TYPE; |
|
| 293 | + if($class->isSubclassOf('TList')) { |
|
| 294 | + return self::LIST_TYPE; |
|
| 295 | + } |
|
| 296 | + if($class->implementsInterface('ArrayAccess')) { |
|
| 297 | + return self::ARRAY_TYPE; |
|
| 298 | + } |
|
| 299 | + } |
|
| 300 | + if(strtolower($type) == 'array') { |
|
| 301 | + return self::ARRAY_TYPE; |
|
| 290 | 302 | } |
| 291 | - if(strtolower($type) == 'array') |
|
| 292 | - return self::ARRAY_TYPE; |
|
| 293 | 303 | } |
| 294 | 304 | |
| 295 | 305 | /** |
@@ -300,8 +310,9 @@ discard block |
||
| 300 | 310 | */ |
| 301 | 311 | public function instanceOfListType($target) |
| 302 | 312 | { |
| 303 | - if($this->getType()===null) |
|
| 304 | - return TPropertyAccess::get($target,$this->getProperty()) instanceof TList; |
|
| 313 | + if($this->getType()===null) { |
|
| 314 | + return TPropertyAccess::get($target,$this->getProperty()) instanceof TList; |
|
| 315 | + } |
|
| 305 | 316 | return $this->getPropertyValueType() == self::LIST_TYPE; |
| 306 | 317 | } |
| 307 | 318 | |
@@ -316,8 +327,9 @@ discard block |
||
| 316 | 327 | if($this->getType()===null) |
| 317 | 328 | { |
| 318 | 329 | $prop = TPropertyAccess::get($target,$this->getProperty()); |
| 319 | - if(is_object($prop)) |
|
| 320 | - return $prop instanceof ArrayAccess; |
|
| 330 | + if(is_object($prop)) { |
|
| 331 | + return $prop instanceof ArrayAccess; |
|
| 332 | + } |
|
| 321 | 333 | return is_array($prop); |
| 322 | 334 | } |
| 323 | 335 | return $this->getPropertyValueType() == self::ARRAY_TYPE; |
@@ -326,16 +338,36 @@ discard block |
||
| 326 | 338 | public function __sleep() |
| 327 | 339 | { |
| 328 | 340 | $exprops = array(); $cn = 'TResultProperty'; |
| 329 | - if ($this->_nullValue===null) $exprops[] = "\0$cn\0_nullValue"; |
|
| 330 | - if ($this->_propertyName===null) $exprops[] = "\0$cn\0_propertyNama"; |
|
| 331 | - if ($this->_columnName===null) $exprops[] = "\0$cn\0_columnName"; |
|
| 332 | - if ($this->_columnIndex==-1) $exprops[] = "\0$cn\0_columnIndex"; |
|
| 333 | - if ($this->_nestedResultMapName===null) $exprops[] = "\0$cn\0_nestedResultMapName"; |
|
| 334 | - if ($this->_nestedResultMap===null) $exprops[] = "\0$cn\0_nestedResultMap"; |
|
| 335 | - if ($this->_valueType===null) $exprops[] = "\0$cn\0_valueType"; |
|
| 336 | - if ($this->_typeHandler===null) $exprops[] = "\0$cn\0_typeHandler"; |
|
| 337 | - if ($this->_isLazyLoad===false) $exprops[] = "\0$cn\0_isLazyLoad"; |
|
| 338 | - if ($this->_select===null) $exprops[] = "\0$cn\0_select"; |
|
| 341 | + if ($this->_nullValue===null) { |
|
| 342 | + $exprops[] = "\0$cn\0_nullValue"; |
|
| 343 | + } |
|
| 344 | + if ($this->_propertyName===null) { |
|
| 345 | + $exprops[] = "\0$cn\0_propertyNama"; |
|
| 346 | + } |
|
| 347 | + if ($this->_columnName===null) { |
|
| 348 | + $exprops[] = "\0$cn\0_columnName"; |
|
| 349 | + } |
|
| 350 | + if ($this->_columnIndex==-1) { |
|
| 351 | + $exprops[] = "\0$cn\0_columnIndex"; |
|
| 352 | + } |
|
| 353 | + if ($this->_nestedResultMapName===null) { |
|
| 354 | + $exprops[] = "\0$cn\0_nestedResultMapName"; |
|
| 355 | + } |
|
| 356 | + if ($this->_nestedResultMap===null) { |
|
| 357 | + $exprops[] = "\0$cn\0_nestedResultMap"; |
|
| 358 | + } |
|
| 359 | + if ($this->_valueType===null) { |
|
| 360 | + $exprops[] = "\0$cn\0_valueType"; |
|
| 361 | + } |
|
| 362 | + if ($this->_typeHandler===null) { |
|
| 363 | + $exprops[] = "\0$cn\0_typeHandler"; |
|
| 364 | + } |
|
| 365 | + if ($this->_isLazyLoad===false) { |
|
| 366 | + $exprops[] = "\0$cn\0_isLazyLoad"; |
|
| 367 | + } |
|
| 368 | + if ($this->_select===null) { |
|
| 369 | + $exprops[] = "\0$cn\0_select"; |
|
| 370 | + } |
|
| 339 | 371 | return array_diff(parent::__sleep(),$exprops); |
| 340 | 372 | } |
| 341 | 373 | } |
@@ -73,6 +73,7 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | 75 | * @param string cache implements of TSqlMapCacheTypes, either 'Basic', 'LRU' or 'FIFO'. |
| 76 | + * @param string $value |
|
| 76 | 77 | */ |
| 77 | 78 | public function setImplementation($value) |
| 78 | 79 | { |
@@ -129,6 +130,7 @@ discard block |
||
| 129 | 130 | /** |
| 130 | 131 | * Register a mapped statement that will trigger a cache flush. |
| 131 | 132 | * @param TMappedStatement mapped statement that may flush the cache. |
| 133 | + * @param IMappedStatement $mappedStatement |
|
| 132 | 134 | */ |
| 133 | 135 | public function registerTriggerStatement($mappedStatement) |
| 134 | 136 | { |
@@ -174,7 +176,7 @@ discard block |
||
| 174 | 176 | } |
| 175 | 177 | |
| 176 | 178 | /** |
| 177 | - * @return float cache hit ratio. |
|
| 179 | + * @return integer cache hit ratio. |
|
| 178 | 180 | */ |
| 179 | 181 | public function getHitRatio() |
| 180 | 182 | { |
@@ -223,7 +225,7 @@ discard block |
||
| 223 | 225 | } |
| 224 | 226 | |
| 225 | 227 | /** |
| 226 | - * @param string serialized object |
|
| 228 | + * @param string string object |
|
| 227 | 229 | * @return string crc32 hash of the serialized object. |
| 228 | 230 | */ |
| 229 | 231 | protected function generateKey($string) |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | private $_hits = 0; |
| 37 | 37 | private $_requests = 0; |
| 38 | 38 | private $_id; |
| 39 | - private $_implementation=TSqlMapCacheTypes::Basic; |
|
| 39 | + private $_implementation = TSqlMapCacheTypes::Basic; |
|
| 40 | 40 | private $_properties = array(); |
| 41 | 41 | private $_flushInterval = 0; |
| 42 | 42 | |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | if (isset(self::$_cacheTypes[$value])) |
| 80 | 80 | $this->_implementation = $value; |
| 81 | 81 | else |
| 82 | - $this->_implementation = TPropertyValue::ensureEnum($value,'TSqlMapCacheTypes'); |
|
| 82 | + $this->_implementation = TPropertyValue::ensureEnum($value, 'TSqlMapCacheTypes'); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | public function setFlushInterval($value) |
| 89 | 89 | { |
| 90 | - $this->_flushInterval=TPropertyValue::ensureInteger($value); |
|
| 90 | + $this->_flushInterval = TPropertyValue::ensureInteger($value); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
@@ -102,12 +102,12 @@ discard block |
||
| 102 | 102 | * Initialize the cache implementation, sets the actual cache contain if supplied. |
| 103 | 103 | * @param ISqLMapCache cache implementation instance. |
| 104 | 104 | */ |
| 105 | - public function initialize($cache=null) |
|
| 105 | + public function initialize($cache = null) |
|
| 106 | 106 | { |
| 107 | - if($cache===null) |
|
| 108 | - $this->_cache= Prado::createComponent($this->getImplementationClass(), $this); |
|
| 107 | + if ($cache === null) |
|
| 108 | + $this->_cache = Prado::createComponent($this->getImplementationClass(), $this); |
|
| 109 | 109 | else |
| 110 | - $this->_cache=$cache; |
|
| 110 | + $this->_cache = $cache; |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | $implementation = $this->_implementation; |
| 119 | 119 | if (isset(self::$_cacheTypes[$implementation])) return self::$_cacheTypes[$implementation]; |
| 120 | 120 | |
| 121 | - switch(TPropertyValue::ensureEnum($implementation,'TSqlMapCacheTypes')) |
|
| 121 | + switch (TPropertyValue::ensureEnum($implementation, 'TSqlMapCacheTypes')) |
|
| 122 | 122 | { |
| 123 | 123 | case TSqlMapCacheTypes::FIFO: return 'TSqlMapFifoCache'; |
| 124 | 124 | case TSqlMapCacheTypes::LRU : return 'TSqlMapLruCache'; |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | */ |
| 133 | 133 | public function registerTriggerStatement($mappedStatement) |
| 134 | 134 | { |
| 135 | - $mappedStatement->attachEventHandler('OnExecuteQuery',array($this, 'flush')); |
|
| 135 | + $mappedStatement->attachEventHandler('OnExecuteQuery', array($this, 'flush')); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
@@ -149,13 +149,13 @@ discard block |
||
| 149 | 149 | */ |
| 150 | 150 | public function get($key) |
| 151 | 151 | { |
| 152 | - if($key instanceof TSqlMapCacheKey) |
|
| 152 | + if ($key instanceof TSqlMapCacheKey) |
|
| 153 | 153 | $key = $key->getHash(); |
| 154 | 154 | |
| 155 | 155 | //if flush ? |
| 156 | 156 | $value = $this->_cache->get($key); |
| 157 | 157 | $this->_requests++; |
| 158 | - if($value!==null) |
|
| 158 | + if ($value !== null) |
|
| 159 | 159 | $this->_hits++; |
| 160 | 160 | return $value; |
| 161 | 161 | } |
@@ -166,10 +166,10 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | public function set($key, $value) |
| 168 | 168 | { |
| 169 | - if($key instanceof TSqlMapCacheKey) |
|
| 169 | + if ($key instanceof TSqlMapCacheKey) |
|
| 170 | 170 | $key = $key->getHash(); |
| 171 | 171 | |
| 172 | - if($value!==null) |
|
| 172 | + if ($value !== null) |
|
| 173 | 173 | $this->_cache->set($key, $value, $this->_flushInterval); |
| 174 | 174 | } |
| 175 | 175 | |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | public function getHitRatio() |
| 180 | 180 | { |
| 181 | - if($this->_requests != 0) |
|
| 181 | + if ($this->_requests != 0) |
|
| 182 | 182 | return $this->_hits / $this->_requests; |
| 183 | 183 | else |
| 184 | 184 | return 0; |
@@ -196,9 +196,9 @@ discard block |
||
| 196 | 196 | */ |
| 197 | 197 | class TSqlMapCacheTypes extends TEnumerable |
| 198 | 198 | { |
| 199 | - const Basic='Basic'; |
|
| 200 | - const FIFO='FIFO'; |
|
| 201 | - const LRU='LRU'; |
|
| 199 | + const Basic = 'Basic'; |
|
| 200 | + const FIFO = 'FIFO'; |
|
| 201 | + const LRU = 'LRU'; |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | */ |
| 229 | 229 | protected function generateKey($string) |
| 230 | 230 | { |
| 231 | - return sprintf('%x',crc32($string)); |
|
| 231 | + return sprintf('%x', crc32($string)); |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | /** |
@@ -76,10 +76,11 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | public function setImplementation($value) |
| 78 | 78 | { |
| 79 | - if (isset(self::$_cacheTypes[$value])) |
|
| 80 | - $this->_implementation = $value; |
|
| 81 | - else |
|
| 82 | - $this->_implementation = TPropertyValue::ensureEnum($value,'TSqlMapCacheTypes'); |
|
| 79 | + if (isset(self::$_cacheTypes[$value])) { |
|
| 80 | + $this->_implementation = $value; |
|
| 81 | + } else { |
|
| 82 | + $this->_implementation = TPropertyValue::ensureEnum($value,'TSqlMapCacheTypes'); |
|
| 83 | + } |
|
| 83 | 84 | } |
| 84 | 85 | |
| 85 | 86 | /** |
@@ -104,10 +105,11 @@ discard block |
||
| 104 | 105 | */ |
| 105 | 106 | public function initialize($cache=null) |
| 106 | 107 | { |
| 107 | - if($cache===null) |
|
| 108 | - $this->_cache= Prado::createComponent($this->getImplementationClass(), $this); |
|
| 109 | - else |
|
| 110 | - $this->_cache=$cache; |
|
| 108 | + if($cache===null) { |
|
| 109 | + $this->_cache= Prado::createComponent($this->getImplementationClass(), $this); |
|
| 110 | + } else { |
|
| 111 | + $this->_cache=$cache; |
|
| 112 | + } |
|
| 111 | 113 | } |
| 112 | 114 | |
| 113 | 115 | /** |
@@ -116,7 +118,9 @@ discard block |
||
| 116 | 118 | public function getImplementationClass() |
| 117 | 119 | { |
| 118 | 120 | $implementation = $this->_implementation; |
| 119 | - if (isset(self::$_cacheTypes[$implementation])) return self::$_cacheTypes[$implementation]; |
|
| 121 | + if (isset(self::$_cacheTypes[$implementation])) { |
|
| 122 | + return self::$_cacheTypes[$implementation]; |
|
| 123 | + } |
|
| 120 | 124 | |
| 121 | 125 | switch(TPropertyValue::ensureEnum($implementation,'TSqlMapCacheTypes')) |
| 122 | 126 | { |
@@ -149,14 +153,16 @@ discard block |
||
| 149 | 153 | */ |
| 150 | 154 | public function get($key) |
| 151 | 155 | { |
| 152 | - if($key instanceof TSqlMapCacheKey) |
|
| 153 | - $key = $key->getHash(); |
|
| 156 | + if($key instanceof TSqlMapCacheKey) { |
|
| 157 | + $key = $key->getHash(); |
|
| 158 | + } |
|
| 154 | 159 | |
| 155 | 160 | //if flush ? |
| 156 | 161 | $value = $this->_cache->get($key); |
| 157 | 162 | $this->_requests++; |
| 158 | - if($value!==null) |
|
| 159 | - $this->_hits++; |
|
| 163 | + if($value!==null) { |
|
| 164 | + $this->_hits++; |
|
| 165 | + } |
|
| 160 | 166 | return $value; |
| 161 | 167 | } |
| 162 | 168 | |
@@ -166,11 +172,13 @@ discard block |
||
| 166 | 172 | */ |
| 167 | 173 | public function set($key, $value) |
| 168 | 174 | { |
| 169 | - if($key instanceof TSqlMapCacheKey) |
|
| 170 | - $key = $key->getHash(); |
|
| 175 | + if($key instanceof TSqlMapCacheKey) { |
|
| 176 | + $key = $key->getHash(); |
|
| 177 | + } |
|
| 171 | 178 | |
| 172 | - if($value!==null) |
|
| 173 | - $this->_cache->set($key, $value, $this->_flushInterval); |
|
| 179 | + if($value!==null) { |
|
| 180 | + $this->_cache->set($key, $value, $this->_flushInterval); |
|
| 181 | + } |
|
| 174 | 182 | } |
| 175 | 183 | |
| 176 | 184 | /** |
@@ -178,10 +186,11 @@ discard block |
||
| 178 | 186 | */ |
| 179 | 187 | public function getHitRatio() |
| 180 | 188 | { |
| 181 | - if($this->_requests != 0) |
|
| 182 | - return $this->_hits / $this->_requests; |
|
| 183 | - else |
|
| 184 | - return 0; |
|
| 189 | + if($this->_requests != 0) { |
|
| 190 | + return $this->_hits / $this->_requests; |
|
| 191 | + } else { |
|
| 192 | + return 0; |
|
| 193 | + } |
|
| 185 | 194 | } |
| 186 | 195 | } |
| 187 | 196 | |
@@ -268,6 +268,7 @@ |
||
| 268 | 268 | * @param TSqlMapTypeHandlerRegistry type handler registry |
| 269 | 269 | * @param string result class name. |
| 270 | 270 | * @param array result data. |
| 271 | + * @param string $type |
|
| 271 | 272 | * @return mixed result object. |
| 272 | 273 | */ |
| 273 | 274 | protected function createInstanceOf($registry,$type,$row=null) |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | public function setID($value) |
| 57 | 57 | { |
| 58 | - $this->_ID=$value; |
|
| 58 | + $this->_ID = $value; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -246,9 +246,9 @@ discard block |
||
| 246 | 246 | */ |
| 247 | 247 | public function initialize($manager) |
| 248 | 248 | { |
| 249 | - if(strlen($this->_resultMapName) > 0) |
|
| 249 | + if (strlen($this->_resultMapName) > 0) |
|
| 250 | 250 | $this->_resultMap = $manager->getResultMap($this->_resultMapName); |
| 251 | - if(strlen($this->_parameterMapName) > 0) |
|
| 251 | + if (strlen($this->_parameterMapName) > 0) |
|
| 252 | 252 | $this->_parameterMap = $manager->getParameterMap($this->_parameterMapName); |
| 253 | 253 | } |
| 254 | 254 | |
@@ -258,8 +258,8 @@ discard block |
||
| 258 | 258 | */ |
| 259 | 259 | public function createInstanceOfListClass($registry) |
| 260 | 260 | { |
| 261 | - if(strlen($type = $this->getListClass()) > 0) |
|
| 262 | - return $this->createInstanceOf($registry,$type); |
|
| 261 | + if (strlen($type = $this->getListClass()) > 0) |
|
| 262 | + return $this->createInstanceOf($registry, $type); |
|
| 263 | 263 | return array(); |
| 264 | 264 | } |
| 265 | 265 | |
@@ -270,10 +270,10 @@ discard block |
||
| 270 | 270 | * @param array result data. |
| 271 | 271 | * @return mixed result object. |
| 272 | 272 | */ |
| 273 | - protected function createInstanceOf($registry,$type,$row=null) |
|
| 273 | + protected function createInstanceOf($registry, $type, $row = null) |
|
| 274 | 274 | { |
| 275 | 275 | $handler = $registry->getTypeHandler($type); |
| 276 | - if($handler!==null) |
|
| 276 | + if ($handler !== null) |
|
| 277 | 277 | return $handler->createNewInstance($row); |
| 278 | 278 | else |
| 279 | 279 | return $registry->createInstanceOf($type); |
@@ -285,10 +285,10 @@ discard block |
||
| 285 | 285 | * @param array result data. |
| 286 | 286 | * @return mixed result object. |
| 287 | 287 | */ |
| 288 | - public function createInstanceOfResultClass($registry,$row) |
|
| 288 | + public function createInstanceOfResultClass($registry, $row) |
|
| 289 | 289 | { |
| 290 | - if(strlen($type= $this->getResultClass()) > 0) |
|
| 291 | - return $this->createInstanceOf($registry,$type,$row); |
|
| 290 | + if (strlen($type = $this->getResultClass()) > 0) |
|
| 291 | + return $this->createInstanceOf($registry, $type, $row); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | public function __sleep() |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | if (!$this->_extendStatement) $exprops[] = "\0$cn\0_extendStatement"; |
| 309 | 309 | if (!$this->_cache) $exprops[] = "\0$cn\0_cache"; |
| 310 | 310 | |
| 311 | - return array_diff(parent::__sleep(),$exprops); |
|
| 311 | + return array_diff(parent::__sleep(), $exprops); |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | } |
@@ -324,8 +324,8 @@ discard block |
||
| 324 | 324 | { |
| 325 | 325 | private $_generate; |
| 326 | 326 | |
| 327 | - public function getGenerate(){ return $this->_generate; } |
|
| 328 | - public function setGenerate($value){ $this->_generate = $value; } |
|
| 327 | + public function getGenerate() { return $this->_generate; } |
|
| 328 | + public function setGenerate($value) { $this->_generate = $value; } |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | /** |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | */ |
| 341 | 341 | class TSqlMapInsert extends TSqlMapStatement |
| 342 | 342 | { |
| 343 | - private $_selectKey=null; |
|
| 343 | + private $_selectKey = null; |
|
| 344 | 344 | |
| 345 | 345 | /** |
| 346 | 346 | * @return TSqlMapSelectKey select key element. |
@@ -246,10 +246,12 @@ discard block |
||
| 246 | 246 | */ |
| 247 | 247 | public function initialize($manager) |
| 248 | 248 | { |
| 249 | - if(strlen($this->_resultMapName) > 0) |
|
| 250 | - $this->_resultMap = $manager->getResultMap($this->_resultMapName); |
|
| 251 | - if(strlen($this->_parameterMapName) > 0) |
|
| 252 | - $this->_parameterMap = $manager->getParameterMap($this->_parameterMapName); |
|
| 249 | + if(strlen($this->_resultMapName) > 0) { |
|
| 250 | + $this->_resultMap = $manager->getResultMap($this->_resultMapName); |
|
| 251 | + } |
|
| 252 | + if(strlen($this->_parameterMapName) > 0) { |
|
| 253 | + $this->_parameterMap = $manager->getParameterMap($this->_parameterMapName); |
|
| 254 | + } |
|
| 253 | 255 | } |
| 254 | 256 | |
| 255 | 257 | /** |
@@ -258,8 +260,9 @@ discard block |
||
| 258 | 260 | */ |
| 259 | 261 | public function createInstanceOfListClass($registry) |
| 260 | 262 | { |
| 261 | - if(strlen($type = $this->getListClass()) > 0) |
|
| 262 | - return $this->createInstanceOf($registry,$type); |
|
| 263 | + if(strlen($type = $this->getListClass()) > 0) { |
|
| 264 | + return $this->createInstanceOf($registry,$type); |
|
| 265 | + } |
|
| 263 | 266 | return array(); |
| 264 | 267 | } |
| 265 | 268 | |
@@ -273,10 +276,11 @@ discard block |
||
| 273 | 276 | protected function createInstanceOf($registry,$type,$row=null) |
| 274 | 277 | { |
| 275 | 278 | $handler = $registry->getTypeHandler($type); |
| 276 | - if($handler!==null) |
|
| 277 | - return $handler->createNewInstance($row); |
|
| 278 | - else |
|
| 279 | - return $registry->createInstanceOf($type); |
|
| 279 | + if($handler!==null) { |
|
| 280 | + return $handler->createNewInstance($row); |
|
| 281 | + } else { |
|
| 282 | + return $registry->createInstanceOf($type); |
|
| 283 | + } |
|
| 280 | 284 | } |
| 281 | 285 | |
| 282 | 286 | /** |
@@ -287,26 +291,51 @@ discard block |
||
| 287 | 291 | */ |
| 288 | 292 | public function createInstanceOfResultClass($registry,$row) |
| 289 | 293 | { |
| 290 | - if(strlen($type= $this->getResultClass()) > 0) |
|
| 291 | - return $this->createInstanceOf($registry,$type,$row); |
|
| 294 | + if(strlen($type= $this->getResultClass()) > 0) { |
|
| 295 | + return $this->createInstanceOf($registry,$type,$row); |
|
| 296 | + } |
|
| 292 | 297 | } |
| 293 | 298 | |
| 294 | 299 | public function __sleep() |
| 295 | 300 | { |
| 296 | 301 | $cn = __CLASS__; |
| 297 | 302 | $exprops = array("\0$cn\0_resultMap"); |
| 298 | - if (!$this->_parameterMapName) $exprops[] = "\0$cn\0_parameterMapName"; |
|
| 299 | - if (!$this->_parameterMap) $exprops[] = "\0$cn\0_parameterMap"; |
|
| 300 | - if (!$this->_parameterClassName) $exprops[] = "\0$cn\0_parameterClassName"; |
|
| 301 | - if (!$this->_resultMapName) $exprops[] = "\0$cn\0_resultMapName"; |
|
| 302 | - if (!$this->_resultMap) $exprops[] = "\0$cn\0_resultMap"; |
|
| 303 | - if (!$this->_resultClassName) $exprops[] = "\0$cn\0_resultClassName"; |
|
| 304 | - if (!$this->_cacheModelName) $exprops[] = "\0$cn\0_cacheModelName"; |
|
| 305 | - if (!$this->_SQL) $exprops[] = "\0$cn\0_SQL"; |
|
| 306 | - if (!$this->_listClass) $exprops[] = "\0$cn\0_listClass"; |
|
| 307 | - if (!$this->_typeHandler) $exprops[] = "\0$cn\0_typeHandler"; |
|
| 308 | - if (!$this->_extendStatement) $exprops[] = "\0$cn\0_extendStatement"; |
|
| 309 | - if (!$this->_cache) $exprops[] = "\0$cn\0_cache"; |
|
| 303 | + if (!$this->_parameterMapName) { |
|
| 304 | + $exprops[] = "\0$cn\0_parameterMapName"; |
|
| 305 | + } |
|
| 306 | + if (!$this->_parameterMap) { |
|
| 307 | + $exprops[] = "\0$cn\0_parameterMap"; |
|
| 308 | + } |
|
| 309 | + if (!$this->_parameterClassName) { |
|
| 310 | + $exprops[] = "\0$cn\0_parameterClassName"; |
|
| 311 | + } |
|
| 312 | + if (!$this->_resultMapName) { |
|
| 313 | + $exprops[] = "\0$cn\0_resultMapName"; |
|
| 314 | + } |
|
| 315 | + if (!$this->_resultMap) { |
|
| 316 | + $exprops[] = "\0$cn\0_resultMap"; |
|
| 317 | + } |
|
| 318 | + if (!$this->_resultClassName) { |
|
| 319 | + $exprops[] = "\0$cn\0_resultClassName"; |
|
| 320 | + } |
|
| 321 | + if (!$this->_cacheModelName) { |
|
| 322 | + $exprops[] = "\0$cn\0_cacheModelName"; |
|
| 323 | + } |
|
| 324 | + if (!$this->_SQL) { |
|
| 325 | + $exprops[] = "\0$cn\0_SQL"; |
|
| 326 | + } |
|
| 327 | + if (!$this->_listClass) { |
|
| 328 | + $exprops[] = "\0$cn\0_listClass"; |
|
| 329 | + } |
|
| 330 | + if (!$this->_typeHandler) { |
|
| 331 | + $exprops[] = "\0$cn\0_typeHandler"; |
|
| 332 | + } |
|
| 333 | + if (!$this->_extendStatement) { |
|
| 334 | + $exprops[] = "\0$cn\0_extendStatement"; |
|
| 335 | + } |
|
| 336 | + if (!$this->_cache) { |
|
| 337 | + $exprops[] = "\0$cn\0_cache"; |
|
| 338 | + } |
|
| 310 | 339 | |
| 311 | 340 | return array_diff(parent::__sleep(),$exprops); |
| 312 | 341 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * Create an instance of an object give by the attribute named 'class' in the |
| 24 | 24 | * node and set the properties on the object given by attribute names and values. |
| 25 | 25 | * @param SimpleXmlNode property node |
| 26 | - * @return Object new instance of class with class name given by 'class' attribute value. |
|
| 26 | + * @return TComponent new instance of class with class name given by 'class' attribute value. |
|
| 27 | 27 | */ |
| 28 | 28 | protected function createObjectFromNode($node) |
| 29 | 29 | { |
@@ -44,6 +44,7 @@ discard block |
||
| 44 | 44 | * @param Object object instance |
| 45 | 45 | * @param SimpleXmlNode property node |
| 46 | 46 | * @param array exception property name |
| 47 | + * @param TComponent $obj |
|
| 47 | 48 | */ |
| 48 | 49 | protected function setObjectPropFromNode($obj,$node,$except=array()) |
| 49 | 50 | { |
@@ -65,6 +66,8 @@ discard block |
||
| 65 | 66 | * Gets the filename relative to the basefile. |
| 66 | 67 | * @param string base filename |
| 67 | 68 | * @param string relative filename |
| 69 | + * @param string $basefile |
|
| 70 | + * @param string $resource |
|
| 68 | 71 | * @return string absolute filename. |
| 69 | 72 | */ |
| 70 | 73 | protected function getAbsoluteFilePath($basefile,$resource) |
@@ -98,9 +101,10 @@ discard block |
||
| 98 | 101 | |
| 99 | 102 | /** |
| 100 | 103 | * Get element node by ID value (try for attribute name ID as case insensitive). |
| 101 | - * @param SimpleXmlDocument $document |
|
| 104 | + * @param SimpleXMLElement $document |
|
| 102 | 105 | * @param string tag name. |
| 103 | 106 | * @param string id value. |
| 107 | + * @param string $tag |
|
| 104 | 108 | * @return SimpleXmlElement node if found, null otherwise. |
| 105 | 109 | */ |
| 106 | 110 | protected function getElementByIdValue($document, $tag, $value) |
@@ -146,6 +150,7 @@ discard block |
||
| 146 | 150 | |
| 147 | 151 | /** |
| 148 | 152 | * @param TSqlMapManager manager instance. |
| 153 | + * @param TSqlMapManager $manager |
|
| 149 | 154 | */ |
| 150 | 155 | public function __construct($manager) |
| 151 | 156 | { |
@@ -524,6 +529,7 @@ discard block |
||
| 524 | 529 | * in the sql text. Extracts inline parameter maps. |
| 525 | 530 | * @param TSqlMapStatement mapped statement. |
| 526 | 531 | * @param SimpleXmlElement statement node. |
| 532 | + * @param TSqlMapStatement $statement |
|
| 527 | 533 | */ |
| 528 | 534 | protected function processSqlStatement($statement, $node) |
| 529 | 535 | { |
@@ -547,6 +553,7 @@ discard block |
||
| 547 | 553 | * @param TSqlMapStatement statement object. |
| 548 | 554 | * @param string sql text |
| 549 | 555 | * @param SimpleXmlElement statement node. |
| 556 | + * @param string $sqlStatement |
|
| 550 | 557 | */ |
| 551 | 558 | protected function applyInlineParameterMap($statement, $sqlStatement, $node) |
| 552 | 559 | { |
@@ -644,6 +651,7 @@ discard block |
||
| 644 | 651 | /** |
| 645 | 652 | * Load the selectKey statement from xml mapping. |
| 646 | 653 | * @param SimpleXmlElement selectkey node |
| 654 | + * @param TSqlMapInsert $insert |
|
| 647 | 655 | */ |
| 648 | 656 | protected function loadSelectKeyTag($insert, $node) |
| 649 | 657 | { |
@@ -734,6 +742,7 @@ discard block |
||
| 734 | 742 | * Load the flush interval |
| 735 | 743 | * @param TSqlMapCacheModel cache model |
| 736 | 744 | * @param SimpleXmlElement cache node |
| 745 | + * @param TSqlMapCacheModel $cacheModel |
|
| 737 | 746 | */ |
| 738 | 747 | protected function loadFlushInterval($cacheModel, $node) |
| 739 | 748 | { |
@@ -769,6 +778,7 @@ discard block |
||
| 769 | 778 | * @param TSqlMapCacheModel cache model |
| 770 | 779 | * @param SimpleXmlElement parent node. |
| 771 | 780 | * @param SimpleXmlElement flush node. |
| 781 | + * @param TSqlMapCacheModel $cacheModel |
|
| 772 | 782 | */ |
| 773 | 783 | protected function loadFlushOnCache($cacheModel,$parent,$node) |
| 774 | 784 | { |
@@ -27,10 +27,10 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | protected function createObjectFromNode($node) |
| 29 | 29 | { |
| 30 | - if(isset($node['class'])) |
|
| 30 | + if (isset($node['class'])) |
|
| 31 | 31 | { |
| 32 | - $obj = Prado::createComponent((string)$node['class']); |
|
| 33 | - $this->setObjectPropFromNode($obj,$node,array('class')); |
|
| 32 | + $obj = Prado::createComponent((string) $node['class']); |
|
| 33 | + $this->setObjectPropFromNode($obj, $node, array('class')); |
|
| 34 | 34 | return $obj; |
| 35 | 35 | } |
| 36 | 36 | throw new TSqlMapConfigurationException( |
@@ -45,14 +45,14 @@ discard block |
||
| 45 | 45 | * @param SimpleXmlNode property node |
| 46 | 46 | * @param array exception property name |
| 47 | 47 | */ |
| 48 | - protected function setObjectPropFromNode($obj,$node,$except=array()) |
|
| 48 | + protected function setObjectPropFromNode($obj, $node, $except = array()) |
|
| 49 | 49 | { |
| 50 | - foreach($node->attributes() as $name=>$value) |
|
| 50 | + foreach ($node->attributes() as $name=>$value) |
|
| 51 | 51 | { |
| 52 | - if(!in_array($name,$except)) |
|
| 52 | + if (!in_array($name, $except)) |
|
| 53 | 53 | { |
| 54 | - if($obj->canSetProperty($name)) |
|
| 55 | - $obj->{$name} = (string)$value; |
|
| 54 | + if ($obj->canSetProperty($name)) |
|
| 55 | + $obj->{$name} = (string) $value; |
|
| 56 | 56 | else |
| 57 | 57 | throw new TSqlMapConfigurationException( |
| 58 | 58 | 'sqlmap_invalid_property', $name, get_class($obj), |
@@ -67,13 +67,13 @@ discard block |
||
| 67 | 67 | * @param string relative filename |
| 68 | 68 | * @return string absolute filename. |
| 69 | 69 | */ |
| 70 | - protected function getAbsoluteFilePath($basefile,$resource) |
|
| 70 | + protected function getAbsoluteFilePath($basefile, $resource) |
|
| 71 | 71 | { |
| 72 | 72 | $basedir = dirname($basefile); |
| 73 | - $file = realpath($basedir.DIRECTORY_SEPARATOR.$resource); |
|
| 74 | - if(!is_string($file) || !is_file($file)) |
|
| 73 | + $file = realpath($basedir . DIRECTORY_SEPARATOR . $resource); |
|
| 74 | + if (!is_string($file) || !is_file($file)) |
|
| 75 | 75 | $file = realpath($resource); |
| 76 | - if(is_string($file) && is_file($file)) |
|
| 76 | + if (is_string($file) && is_file($file)) |
|
| 77 | 77 | return $file; |
| 78 | 78 | else |
| 79 | 79 | throw new TSqlMapConfigurationException( |
@@ -85,12 +85,12 @@ discard block |
||
| 85 | 85 | * @param string filename. |
| 86 | 86 | * @return SimpleXmlElement xml document. |
| 87 | 87 | */ |
| 88 | - protected function loadXmlDocument($filename,TSqlMapXmlConfiguration $config) |
|
| 88 | + protected function loadXmlDocument($filename, TSqlMapXmlConfiguration $config) |
|
| 89 | 89 | { |
| 90 | - if( strpos($filename, '${') !== false) |
|
| 90 | + if (strpos($filename, '${') !== false) |
|
| 91 | 91 | $filename = $config->replaceProperties($filename); |
| 92 | 92 | |
| 93 | - if(!is_file($filename)) |
|
| 93 | + if (!is_file($filename)) |
|
| 94 | 94 | throw new TSqlMapConfigurationException( |
| 95 | 95 | 'sqlmap_unable_to_find_config', $filename); |
| 96 | 96 | return simplexml_load_string($config->replaceProperties(file_get_contents($filename))); |
@@ -106,10 +106,10 @@ discard block |
||
| 106 | 106 | protected function getElementByIdValue($document, $tag, $value) |
| 107 | 107 | { |
| 108 | 108 | //hack to allow upper case and lower case attribute names. |
| 109 | - foreach(array('id','ID','Id', 'iD') as $id) |
|
| 109 | + foreach (array('id', 'ID', 'Id', 'iD') as $id) |
|
| 110 | 110 | { |
| 111 | 111 | $xpath = "//{$tag}[@{$id}='{$value}']"; |
| 112 | - foreach($document->xpath($xpath) as $node) |
|
| 112 | + foreach ($document->xpath($xpath) as $node) |
|
| 113 | 113 | return $node; |
| 114 | 114 | } |
| 115 | 115 | } |
@@ -142,14 +142,14 @@ discard block |
||
| 142 | 142 | /** |
| 143 | 143 | * @var array global properties. |
| 144 | 144 | */ |
| 145 | - private $_properties=array(); |
|
| 145 | + private $_properties = array(); |
|
| 146 | 146 | |
| 147 | 147 | /** |
| 148 | 148 | * @param TSqlMapManager manager instance. |
| 149 | 149 | */ |
| 150 | 150 | public function __construct($manager) |
| 151 | 151 | { |
| 152 | - $this->_manager=$manager; |
|
| 152 | + $this->_manager = $manager; |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | public function getManager() |
@@ -166,25 +166,25 @@ discard block |
||
| 166 | 166 | * Configure the TSqlMapManager using the given xml file. |
| 167 | 167 | * @param string SqlMap configuration xml file. |
| 168 | 168 | */ |
| 169 | - public function configure($filename=null) |
|
| 169 | + public function configure($filename = null) |
|
| 170 | 170 | { |
| 171 | - $this->_configFile=$filename; |
|
| 172 | - $document = $this->loadXmlDocument($filename,$this); |
|
| 171 | + $this->_configFile = $filename; |
|
| 172 | + $document = $this->loadXmlDocument($filename, $this); |
|
| 173 | 173 | |
| 174 | - foreach($document->xpath('//property') as $property) |
|
| 174 | + foreach ($document->xpath('//property') as $property) |
|
| 175 | 175 | $this->loadGlobalProperty($property); |
| 176 | 176 | |
| 177 | - foreach($document->xpath('//typeHandler') as $handler) |
|
| 177 | + foreach ($document->xpath('//typeHandler') as $handler) |
|
| 178 | 178 | $this->loadTypeHandler($handler); |
| 179 | 179 | |
| 180 | - foreach($document->xpath('//connection[last()]') as $conn) |
|
| 180 | + foreach ($document->xpath('//connection[last()]') as $conn) |
|
| 181 | 181 | $this->loadDatabaseConnection($conn); |
| 182 | 182 | |
| 183 | 183 | //try to load configuration in the current config file. |
| 184 | 184 | $mapping = new TSqlMapXmlMappingConfiguration($this); |
| 185 | 185 | $mapping->configure($filename); |
| 186 | 186 | |
| 187 | - foreach($document->xpath('//sqlMap') as $sqlmap) |
|
| 187 | + foreach ($document->xpath('//sqlMap') as $sqlmap) |
|
| 188 | 188 | $this->loadSqlMappingFiles($sqlmap); |
| 189 | 189 | |
| 190 | 190 | $this->resolveResultMapping(); |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | */ |
| 198 | 198 | protected function loadGlobalProperty($node) |
| 199 | 199 | { |
| 200 | - $this->_properties[(string)$node['name']] = (string)$node['value']; |
|
| 200 | + $this->_properties[(string) $node['name']] = (string) $node['value']; |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -226,9 +226,9 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | protected function loadSqlMappingFiles($node) |
| 228 | 228 | { |
| 229 | - if(strlen($resource = (string)$node['resource']) > 0) |
|
| 229 | + if (strlen($resource = (string) $node['resource']) > 0) |
|
| 230 | 230 | { |
| 231 | - if( strpos($resource, '${') !== false) |
|
| 231 | + if (strpos($resource, '${') !== false) |
|
| 232 | 232 | $resource = $this->replaceProperties($resource); |
| 233 | 233 | |
| 234 | 234 | $mapping = new TSqlMapXmlMappingConfiguration($this); |
@@ -243,14 +243,14 @@ discard block |
||
| 243 | 243 | protected function resolveResultMapping() |
| 244 | 244 | { |
| 245 | 245 | $maps = $this->_manager->getResultMaps(); |
| 246 | - foreach($maps as $entry) |
|
| 246 | + foreach ($maps as $entry) |
|
| 247 | 247 | { |
| 248 | - foreach($entry->getColumns() as $item) |
|
| 248 | + foreach ($entry->getColumns() as $item) |
|
| 249 | 249 | { |
| 250 | 250 | $resultMap = $item->getResultMapping(); |
| 251 | - if(strlen($resultMap) > 0) |
|
| 251 | + if (strlen($resultMap) > 0) |
|
| 252 | 252 | { |
| 253 | - if($maps->contains($resultMap)) |
|
| 253 | + if ($maps->contains($resultMap)) |
|
| 254 | 254 | $item->setNestedResultMap($maps[$resultMap]); |
| 255 | 255 | else |
| 256 | 256 | throw new TSqlMapConfigurationException( |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | $resultMap, $this->_configFile, $entry->getID()); |
| 259 | 259 | } |
| 260 | 260 | } |
| 261 | - if($entry->getDiscriminator()!==null) |
|
| 261 | + if ($entry->getDiscriminator() !== null) |
|
| 262 | 262 | $entry->getDiscriminator()->initialize($this->_manager); |
| 263 | 263 | } |
| 264 | 264 | } |
@@ -268,9 +268,9 @@ discard block |
||
| 268 | 268 | */ |
| 269 | 269 | protected function attachCacheModels() |
| 270 | 270 | { |
| 271 | - foreach($this->_manager->getMappedStatements() as $mappedStatement) |
|
| 271 | + foreach ($this->_manager->getMappedStatements() as $mappedStatement) |
|
| 272 | 272 | { |
| 273 | - if(strlen($model = $mappedStatement->getStatement()->getCacheModel()) > 0) |
|
| 273 | + if (strlen($model = $mappedStatement->getStatement()->getCacheModel()) > 0) |
|
| 274 | 274 | { |
| 275 | 275 | $cache = $this->_manager->getCacheModel($model); |
| 276 | 276 | $mappedStatement->getStatement()->setCache($cache); |
@@ -286,8 +286,8 @@ discard block |
||
| 286 | 286 | */ |
| 287 | 287 | public function replaceProperties($string) |
| 288 | 288 | { |
| 289 | - foreach($this->_properties as $find => $replace) |
|
| 290 | - $string = str_replace('${'.$find.'}', $replace, $string); |
|
| 289 | + foreach ($this->_properties as $find => $replace) |
|
| 290 | + $string = str_replace('${' . $find . '}', $replace, $string); |
|
| 291 | 291 | return $string; |
| 292 | 292 | } |
| 293 | 293 | } |
@@ -309,25 +309,25 @@ discard block |
||
| 309 | 309 | |
| 310 | 310 | private $_document; |
| 311 | 311 | |
| 312 | - private $_FlushOnExecuteStatements=array(); |
|
| 312 | + private $_FlushOnExecuteStatements = array(); |
|
| 313 | 313 | |
| 314 | 314 | /** |
| 315 | 315 | * Regular expressions for escaping simple/inline parameter symbols |
| 316 | 316 | */ |
| 317 | - const SIMPLE_MARK='$'; |
|
| 318 | - const INLINE_SYMBOL='#'; |
|
| 319 | - const ESCAPED_SIMPLE_MARK_REGEXP='/\$\$/'; |
|
| 320 | - const ESCAPED_INLINE_SYMBOL_REGEXP='/\#\#/'; |
|
| 321 | - const SIMPLE_PLACEHOLDER='`!!`'; |
|
| 322 | - const INLINE_PLACEHOLDER='`!!!`'; |
|
| 317 | + const SIMPLE_MARK = '$'; |
|
| 318 | + const INLINE_SYMBOL = '#'; |
|
| 319 | + const ESCAPED_SIMPLE_MARK_REGEXP = '/\$\$/'; |
|
| 320 | + const ESCAPED_INLINE_SYMBOL_REGEXP = '/\#\#/'; |
|
| 321 | + const SIMPLE_PLACEHOLDER = '`!!`'; |
|
| 322 | + const INLINE_PLACEHOLDER = '`!!!`'; |
|
| 323 | 323 | |
| 324 | 324 | /** |
| 325 | 325 | * @param TSqlMapXmlConfiguration parent xml configuration. |
| 326 | 326 | */ |
| 327 | 327 | public function __construct(TSqlMapXmlConfiguration $xmlConfig) |
| 328 | 328 | { |
| 329 | - $this->_xmlConfig=$xmlConfig; |
|
| 330 | - $this->_manager=$xmlConfig->getManager(); |
|
| 329 | + $this->_xmlConfig = $xmlConfig; |
|
| 330 | + $this->_manager = $xmlConfig->getManager(); |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | protected function getConfigFile() |
@@ -341,44 +341,44 @@ discard block |
||
| 341 | 341 | */ |
| 342 | 342 | public function configure($filename) |
| 343 | 343 | { |
| 344 | - $this->_configFile=$filename; |
|
| 345 | - $document = $this->loadXmlDocument($filename,$this->_xmlConfig); |
|
| 346 | - $this->_document=$document; |
|
| 344 | + $this->_configFile = $filename; |
|
| 345 | + $document = $this->loadXmlDocument($filename, $this->_xmlConfig); |
|
| 346 | + $this->_document = $document; |
|
| 347 | 347 | |
| 348 | 348 | static $bCacheDependencies; |
| 349 | - if($bCacheDependencies === null) |
|
| 349 | + if ($bCacheDependencies === null) |
|
| 350 | 350 | $bCacheDependencies = Prado::getApplication()->getMode() !== TApplicationMode::Performance; |
| 351 | 351 | |
| 352 | - if($bCacheDependencies) |
|
| 352 | + if ($bCacheDependencies) |
|
| 353 | 353 | $this->_manager->getCacheDependencies() |
| 354 | 354 | ->getDependencies() |
| 355 | 355 | ->add(new TFileCacheDependency($filename)); |
| 356 | 356 | |
| 357 | - foreach($document->xpath('//resultMap') as $node) |
|
| 357 | + foreach ($document->xpath('//resultMap') as $node) |
|
| 358 | 358 | $this->loadResultMap($node); |
| 359 | 359 | |
| 360 | - foreach($document->xpath('//parameterMap') as $node) |
|
| 360 | + foreach ($document->xpath('//parameterMap') as $node) |
|
| 361 | 361 | $this->loadParameterMap($node); |
| 362 | 362 | |
| 363 | - foreach($document->xpath('//statement') as $node) |
|
| 363 | + foreach ($document->xpath('//statement') as $node) |
|
| 364 | 364 | $this->loadStatementTag($node); |
| 365 | 365 | |
| 366 | - foreach($document->xpath('//select') as $node) |
|
| 366 | + foreach ($document->xpath('//select') as $node) |
|
| 367 | 367 | $this->loadSelectTag($node); |
| 368 | 368 | |
| 369 | - foreach($document->xpath('//insert') as $node) |
|
| 369 | + foreach ($document->xpath('//insert') as $node) |
|
| 370 | 370 | $this->loadInsertTag($node); |
| 371 | 371 | |
| 372 | - foreach($document->xpath('//update') as $node) |
|
| 372 | + foreach ($document->xpath('//update') as $node) |
|
| 373 | 373 | $this->loadUpdateTag($node); |
| 374 | 374 | |
| 375 | - foreach($document->xpath('//delete') as $node) |
|
| 375 | + foreach ($document->xpath('//delete') as $node) |
|
| 376 | 376 | $this->loadDeleteTag($node); |
| 377 | 377 | |
| 378 | - foreach($document->xpath('//procedure') as $node) |
|
| 378 | + foreach ($document->xpath('//procedure') as $node) |
|
| 379 | 379 | $this->loadProcedureTag($node); |
| 380 | 380 | |
| 381 | - foreach($document->xpath('//cacheModel') as $node) |
|
| 381 | + foreach ($document->xpath('//cacheModel') as $node) |
|
| 382 | 382 | $this->loadCacheModel($node); |
| 383 | 383 | |
| 384 | 384 | $this->registerCacheTriggers(); |
@@ -393,16 +393,16 @@ discard block |
||
| 393 | 393 | $resultMap = $this->createResultMap($node); |
| 394 | 394 | |
| 395 | 395 | //find extended result map. |
| 396 | - if(strlen($extendMap = $resultMap->getExtends()) > 0) |
|
| 396 | + if (strlen($extendMap = $resultMap->getExtends()) > 0) |
|
| 397 | 397 | { |
| 398 | - if(!$this->_manager->getResultMaps()->contains($extendMap)) |
|
| 398 | + if (!$this->_manager->getResultMaps()->contains($extendMap)) |
|
| 399 | 399 | { |
| 400 | - $extendNode=$this->getElementByIdValue($this->_document,'resultMap',$extendMap); |
|
| 401 | - if($extendNode!==null) |
|
| 400 | + $extendNode = $this->getElementByIdValue($this->_document, 'resultMap', $extendMap); |
|
| 401 | + if ($extendNode !== null) |
|
| 402 | 402 | $this->loadResultMap($extendNode); |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | - if(!$this->_manager->getResultMaps()->contains($extendMap)) |
|
| 405 | + if (!$this->_manager->getResultMaps()->contains($extendMap)) |
|
| 406 | 406 | throw new TSqlMapConfigurationException( |
| 407 | 407 | 'sqlmap_unable_to_find_parent_result_map', $node, $this->_configFile, $extendMap); |
| 408 | 408 | |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | //add the result map |
| 414 | - if(!$this->_manager->getResultMaps()->contains($resultMap->getID())) |
|
| 414 | + if (!$this->_manager->getResultMaps()->contains($resultMap->getID())) |
|
| 415 | 415 | $this->_manager->addResultMap($resultMap); |
| 416 | 416 | } |
| 417 | 417 | |
@@ -424,36 +424,36 @@ discard block |
||
| 424 | 424 | protected function createResultMap($node) |
| 425 | 425 | { |
| 426 | 426 | $resultMap = new TResultMap(); |
| 427 | - $this->setObjectPropFromNode($resultMap,$node); |
|
| 427 | + $this->setObjectPropFromNode($resultMap, $node); |
|
| 428 | 428 | |
| 429 | 429 | //result nodes |
| 430 | - foreach($node->result as $result) |
|
| 430 | + foreach ($node->result as $result) |
|
| 431 | 431 | { |
| 432 | 432 | $property = new TResultProperty($resultMap); |
| 433 | - $this->setObjectPropFromNode($property,$result); |
|
| 433 | + $this->setObjectPropFromNode($property, $result); |
|
| 434 | 434 | $resultMap->addResultProperty($property); |
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | //create the discriminator |
| 438 | 438 | $discriminator = null; |
| 439 | - if(isset($node->discriminator)) |
|
| 439 | + if (isset($node->discriminator)) |
|
| 440 | 440 | { |
| 441 | 441 | $discriminator = new TDiscriminator(); |
| 442 | 442 | $this->setObjectPropFromNode($discriminator, $node->discriminator); |
| 443 | 443 | $discriminator->initMapping($resultMap); |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | - foreach($node->xpath('subMap') as $subMapNode) |
|
| 446 | + foreach ($node->xpath('subMap') as $subMapNode) |
|
| 447 | 447 | { |
| 448 | - if($discriminator===null) |
|
| 448 | + if ($discriminator === null) |
|
| 449 | 449 | throw new TSqlMapConfigurationException( |
| 450 | - 'sqlmap_undefined_discriminator', $node, $this->_configFile,$subMapNode); |
|
| 450 | + 'sqlmap_undefined_discriminator', $node, $this->_configFile, $subMapNode); |
|
| 451 | 451 | $subMap = new TSubMap; |
| 452 | - $this->setObjectPropFromNode($subMap,$subMapNode); |
|
| 452 | + $this->setObjectPropFromNode($subMap, $subMapNode); |
|
| 453 | 453 | $discriminator->addSubMap($subMap); |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | - if($discriminator!==null) |
|
| 456 | + if ($discriminator !== null) |
|
| 457 | 457 | $resultMap->setDiscriminator($discriminator); |
| 458 | 458 | |
| 459 | 459 | return $resultMap; |
@@ -468,22 +468,22 @@ discard block |
||
| 468 | 468 | { |
| 469 | 469 | $parameterMap = $this->createParameterMap($node); |
| 470 | 470 | |
| 471 | - if(strlen($extendMap = $parameterMap->getExtends()) > 0) |
|
| 471 | + if (strlen($extendMap = $parameterMap->getExtends()) > 0) |
|
| 472 | 472 | { |
| 473 | - if(!$this->_manager->getParameterMaps()->contains($extendMap)) |
|
| 473 | + if (!$this->_manager->getParameterMaps()->contains($extendMap)) |
|
| 474 | 474 | { |
| 475 | - $extendNode=$this->getElementByIdValue($this->_document,'parameterMap',$extendMap); |
|
| 476 | - if($extendNode!==null) |
|
| 475 | + $extendNode = $this->getElementByIdValue($this->_document, 'parameterMap', $extendMap); |
|
| 476 | + if ($extendNode !== null) |
|
| 477 | 477 | $this->loadParameterMap($extendNode); |
| 478 | 478 | } |
| 479 | 479 | |
| 480 | - if(!$this->_manager->getParameterMaps()->contains($extendMap)) |
|
| 480 | + if (!$this->_manager->getParameterMaps()->contains($extendMap)) |
|
| 481 | 481 | throw new TSqlMapConfigurationException( |
| 482 | - 'sqlmap_unable_to_find_parent_parameter_map', $node, $this->_configFile,$extendMap); |
|
| 482 | + 'sqlmap_unable_to_find_parent_parameter_map', $node, $this->_configFile, $extendMap); |
|
| 483 | 483 | $superMap = $this->_manager->getParameterMap($extendMap); |
| 484 | 484 | $index = 0; |
| 485 | - foreach($superMap->getPropertyNames() as $propertyName) |
|
| 486 | - $parameterMap->insertProperty($index++,$superMap->getProperty($propertyName)); |
|
| 485 | + foreach ($superMap->getPropertyNames() as $propertyName) |
|
| 486 | + $parameterMap->insertProperty($index++, $superMap->getProperty($propertyName)); |
|
| 487 | 487 | } |
| 488 | 488 | $this->_manager->addParameterMap($parameterMap); |
| 489 | 489 | } |
@@ -496,11 +496,11 @@ discard block |
||
| 496 | 496 | protected function createParameterMap($node) |
| 497 | 497 | { |
| 498 | 498 | $parameterMap = new TParameterMap(); |
| 499 | - $this->setObjectPropFromNode($parameterMap,$node); |
|
| 500 | - foreach($node->parameter as $parameter) |
|
| 499 | + $this->setObjectPropFromNode($parameterMap, $node); |
|
| 500 | + foreach ($node->parameter as $parameter) |
|
| 501 | 501 | { |
| 502 | 502 | $property = new TParameterProperty(); |
| 503 | - $this->setObjectPropFromNode($property,$parameter); |
|
| 503 | + $this->setObjectPropFromNode($property, $parameter); |
|
| 504 | 504 | $parameterMap->addProperty($property); |
| 505 | 505 | } |
| 506 | 506 | return $parameterMap; |
@@ -513,7 +513,7 @@ discard block |
||
| 513 | 513 | protected function loadStatementTag($node) |
| 514 | 514 | { |
| 515 | 515 | $statement = new TSqlMapStatement(); |
| 516 | - $this->setObjectPropFromNode($statement,$node); |
|
| 516 | + $this->setObjectPropFromNode($statement, $node); |
|
| 517 | 517 | $this->processSqlStatement($statement, $node); |
| 518 | 518 | $mappedStatement = new TMappedStatement($this->_manager, $statement); |
| 519 | 519 | $this->_manager->addMappedStatement($mappedStatement); |
@@ -527,15 +527,15 @@ discard block |
||
| 527 | 527 | */ |
| 528 | 528 | protected function processSqlStatement($statement, $node) |
| 529 | 529 | { |
| 530 | - $commandText = (string)$node; |
|
| 531 | - if(strlen($extend = $statement->getExtends()) > 0) |
|
| 530 | + $commandText = (string) $node; |
|
| 531 | + if (strlen($extend = $statement->getExtends()) > 0) |
|
| 532 | 532 | { |
| 533 | - $superNode = $this->getElementByIdValue($this->_document,'*',$extend); |
|
| 534 | - if($superNode!==null) |
|
| 535 | - $commandText = (string)$superNode . $commandText; |
|
| 533 | + $superNode = $this->getElementByIdValue($this->_document, '*', $extend); |
|
| 534 | + if ($superNode !== null) |
|
| 535 | + $commandText = (string) $superNode . $commandText; |
|
| 536 | 536 | else |
| 537 | 537 | throw new TSqlMapConfigurationException( |
| 538 | - 'sqlmap_unable_to_find_parent_sql', $extend, $this->_configFile,$node); |
|
| 538 | + 'sqlmap_unable_to_find_parent_sql', $extend, $this->_configFile, $node); |
|
| 539 | 539 | } |
| 540 | 540 | //$commandText = $this->_xmlConfig->replaceProperties($commandText); |
| 541 | 541 | $statement->initialize($this->_manager); |
@@ -553,24 +553,24 @@ discard block |
||
| 553 | 553 | $scope['file'] = $this->_configFile; |
| 554 | 554 | $scope['node'] = $node; |
| 555 | 555 | |
| 556 | - $sqlStatement=preg_replace(self::ESCAPED_INLINE_SYMBOL_REGEXP,self::INLINE_PLACEHOLDER,$sqlStatement); |
|
| 557 | - if($statement->parameterMap() === null) |
|
| 556 | + $sqlStatement = preg_replace(self::ESCAPED_INLINE_SYMBOL_REGEXP, self::INLINE_PLACEHOLDER, $sqlStatement); |
|
| 557 | + if ($statement->parameterMap() === null) |
|
| 558 | 558 | { |
| 559 | 559 | // Build a Parametermap with the inline parameters. |
| 560 | 560 | // if they exist. Then delete inline infos from sqltext. |
| 561 | 561 | $parameterParser = new TInlineParameterMapParser; |
| 562 | 562 | $sqlText = $parameterParser->parse($sqlStatement, $scope); |
| 563 | - if(count($sqlText['parameters']) > 0) |
|
| 563 | + if (count($sqlText['parameters']) > 0) |
|
| 564 | 564 | { |
| 565 | 565 | $map = new TParameterMap(); |
| 566 | - $map->setID($statement->getID().'-InLineParameterMap'); |
|
| 566 | + $map->setID($statement->getID() . '-InLineParameterMap'); |
|
| 567 | 567 | $statement->setInlineParameterMap($map); |
| 568 | - foreach($sqlText['parameters'] as $property) |
|
| 568 | + foreach ($sqlText['parameters'] as $property) |
|
| 569 | 569 | $map->addProperty($property); |
| 570 | 570 | } |
| 571 | 571 | $sqlStatement = $sqlText['sql']; |
| 572 | 572 | } |
| 573 | - $sqlStatement=preg_replace('/'.self::INLINE_PLACEHOLDER.'/',self::INLINE_SYMBOL,$sqlStatement); |
|
| 573 | + $sqlStatement = preg_replace('/' . self::INLINE_PLACEHOLDER . '/', self::INLINE_SYMBOL, $sqlStatement); |
|
| 574 | 574 | |
| 575 | 575 | $this->prepareSql($statement, $sqlStatement, $node); |
| 576 | 576 | } |
@@ -582,19 +582,19 @@ discard block |
||
| 582 | 582 | * @param SimpleXmlElement statement node. |
| 583 | 583 | * @todo Extend to dynamic sql. |
| 584 | 584 | */ |
| 585 | - protected function prepareSql($statement,$sqlStatement, $node) |
|
| 585 | + protected function prepareSql($statement, $sqlStatement, $node) |
|
| 586 | 586 | { |
| 587 | 587 | $simpleDynamic = new TSimpleDynamicParser; |
| 588 | - $sqlStatement=preg_replace(self::ESCAPED_SIMPLE_MARK_REGEXP,self::SIMPLE_PLACEHOLDER,$sqlStatement); |
|
| 588 | + $sqlStatement = preg_replace(self::ESCAPED_SIMPLE_MARK_REGEXP, self::SIMPLE_PLACEHOLDER, $sqlStatement); |
|
| 589 | 589 | $dynamics = $simpleDynamic->parse($sqlStatement); |
| 590 | - if(count($dynamics['parameters']) > 0) |
|
| 590 | + if (count($dynamics['parameters']) > 0) |
|
| 591 | 591 | { |
| 592 | 592 | $sql = new TSimpleDynamicSql($dynamics['parameters']); |
| 593 | 593 | $sqlStatement = $dynamics['sql']; |
| 594 | 594 | } |
| 595 | 595 | else |
| 596 | 596 | $sql = new TStaticSql(); |
| 597 | - $sqlStatement=preg_replace('/'.self::SIMPLE_PLACEHOLDER.'/',self::SIMPLE_MARK,$sqlStatement); |
|
| 597 | + $sqlStatement = preg_replace('/' . self::SIMPLE_PLACEHOLDER . '/', self::SIMPLE_MARK, $sqlStatement); |
|
| 598 | 598 | $sql->buildPreparedStatement($statement, $sqlStatement); |
| 599 | 599 | $statement->setSqlText($sql); |
| 600 | 600 | } |
@@ -606,10 +606,10 @@ discard block |
||
| 606 | 606 | protected function loadSelectTag($node) |
| 607 | 607 | { |
| 608 | 608 | $select = new TSqlMapSelect; |
| 609 | - $this->setObjectPropFromNode($select,$node); |
|
| 610 | - $this->processSqlStatement($select,$node); |
|
| 609 | + $this->setObjectPropFromNode($select, $node); |
|
| 610 | + $this->processSqlStatement($select, $node); |
|
| 611 | 611 | $mappedStatement = new TMappedStatement($this->_manager, $select); |
| 612 | - if(strlen($select->getCacheModel()) > 0) |
|
| 612 | + if (strlen($select->getCacheModel()) > 0) |
|
| 613 | 613 | $mappedStatement = new TCachingStatement($mappedStatement); |
| 614 | 614 | |
| 615 | 615 | $this->_manager->addMappedStatement($mappedStatement); |
@@ -635,9 +635,9 @@ discard block |
||
| 635 | 635 | protected function createInsertStatement($node) |
| 636 | 636 | { |
| 637 | 637 | $insert = new TSqlMapInsert; |
| 638 | - $this->setObjectPropFromNode($insert,$node); |
|
| 639 | - if(isset($node->selectKey)) |
|
| 640 | - $this->loadSelectKeyTag($insert,$node->selectKey); |
|
| 638 | + $this->setObjectPropFromNode($insert, $node); |
|
| 639 | + if (isset($node->selectKey)) |
|
| 640 | + $this->loadSelectKeyTag($insert, $node->selectKey); |
|
| 641 | 641 | return $insert; |
| 642 | 642 | } |
| 643 | 643 | |
@@ -648,10 +648,10 @@ discard block |
||
| 648 | 648 | protected function loadSelectKeyTag($insert, $node) |
| 649 | 649 | { |
| 650 | 650 | $selectKey = new TSqlMapSelectKey; |
| 651 | - $this->setObjectPropFromNode($selectKey,$node); |
|
| 651 | + $this->setObjectPropFromNode($selectKey, $node); |
|
| 652 | 652 | $selectKey->setID($insert->getID()); |
| 653 | - $selectKey->setID($insert->getID().'.SelectKey'); |
|
| 654 | - $this->processSqlStatement($selectKey,$node); |
|
| 653 | + $selectKey->setID($insert->getID() . '.SelectKey'); |
|
| 654 | + $this->processSqlStatement($selectKey, $node); |
|
| 655 | 655 | $insert->setSelectKey($selectKey); |
| 656 | 656 | $mappedStatement = new TMappedStatement($this->_manager, $selectKey); |
| 657 | 657 | $this->_manager->addMappedStatement($mappedStatement); |
@@ -664,7 +664,7 @@ discard block |
||
| 664 | 664 | protected function loadUpdateTag($node) |
| 665 | 665 | { |
| 666 | 666 | $update = new TSqlMapUpdate; |
| 667 | - $this->setObjectPropFromNode($update,$node); |
|
| 667 | + $this->setObjectPropFromNode($update, $node); |
|
| 668 | 668 | $this->processSqlStatement($update, $node); |
| 669 | 669 | $mappedStatement = new TUpdateMappedStatement($this->_manager, $update); |
| 670 | 670 | $this->_manager->addMappedStatement($mappedStatement); |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | protected function loadDeleteTag($node) |
| 678 | 678 | { |
| 679 | 679 | $delete = new TSqlMapDelete; |
| 680 | - $this->setObjectPropFromNode($delete,$node); |
|
| 680 | + $this->setObjectPropFromNode($delete, $node); |
|
| 681 | 681 | $this->processSqlStatement($delete, $node); |
| 682 | 682 | $mappedStatement = new TDeleteMappedStatement($this->_manager, $delete); |
| 683 | 683 | $this->_manager->addMappedStatement($mappedStatement); |
@@ -700,34 +700,34 @@ discard block |
||
| 700 | 700 | protected function loadCacheModel($node) |
| 701 | 701 | { |
| 702 | 702 | $cacheModel = new TSqlMapCacheModel; |
| 703 | - $properties = array('id','implementation'); |
|
| 704 | - foreach($node->attributes() as $name=>$value) |
|
| 703 | + $properties = array('id', 'implementation'); |
|
| 704 | + foreach ($node->attributes() as $name=>$value) |
|
| 705 | 705 | { |
| 706 | - if(in_array(strtolower($name), $properties)) |
|
| 707 | - $cacheModel->{'set'.$name}((string)$value); |
|
| 706 | + if (in_array(strtolower($name), $properties)) |
|
| 707 | + $cacheModel->{'set' . $name}((string) $value); |
|
| 708 | 708 | } |
| 709 | 709 | $cache = Prado::createComponent($cacheModel->getImplementationClass(), $cacheModel); |
| 710 | - $this->setObjectPropFromNode($cache,$node,$properties); |
|
| 710 | + $this->setObjectPropFromNode($cache, $node, $properties); |
|
| 711 | 711 | |
| 712 | - foreach($node->xpath('property') as $propertyNode) |
|
| 712 | + foreach ($node->xpath('property') as $propertyNode) |
|
| 713 | 713 | { |
| 714 | 714 | $name = $propertyNode->attributes()->name; |
| 715 | - if($name===null || $name==='') continue; |
|
| 715 | + if ($name === null || $name === '') continue; |
|
| 716 | 716 | |
| 717 | 717 | $value = $propertyNode->attributes()->value; |
| 718 | - if($value===null || $value==='') continue; |
|
| 718 | + if ($value === null || $value === '') continue; |
|
| 719 | 719 | |
| 720 | - if( !TPropertyAccess::has($cache, $name) ) continue; |
|
| 720 | + if (!TPropertyAccess::has($cache, $name)) continue; |
|
| 721 | 721 | |
| 722 | 722 | TPropertyAccess::set($cache, $name, $value); |
| 723 | 723 | } |
| 724 | 724 | |
| 725 | - $this->loadFlushInterval($cacheModel,$node); |
|
| 725 | + $this->loadFlushInterval($cacheModel, $node); |
|
| 726 | 726 | |
| 727 | 727 | $cacheModel->initialize($cache); |
| 728 | 728 | $this->_manager->addCacheModel($cacheModel); |
| 729 | - foreach($node->xpath('flushOnExecute') as $flush) |
|
| 730 | - $this->loadFlushOnCache($cacheModel,$node,$flush); |
|
| 729 | + foreach ($node->xpath('flushOnExecute') as $flush) |
|
| 730 | + $this->loadFlushOnCache($cacheModel, $node, $flush); |
|
| 731 | 731 | } |
| 732 | 732 | |
| 733 | 733 | /** |
@@ -738,26 +738,26 @@ discard block |
||
| 738 | 738 | protected function loadFlushInterval($cacheModel, $node) |
| 739 | 739 | { |
| 740 | 740 | $flushInterval = $node->xpath('flushInterval'); |
| 741 | - if($flushInterval === null || count($flushInterval) === 0) return; |
|
| 741 | + if ($flushInterval === null || count($flushInterval) === 0) return; |
|
| 742 | 742 | $duration = 0; |
| 743 | - foreach($flushInterval[0]->attributes() as $name=>$value) |
|
| 743 | + foreach ($flushInterval[0]->attributes() as $name=>$value) |
|
| 744 | 744 | { |
| 745 | - switch(strToLower($name)) |
|
| 745 | + switch (strToLower($name)) |
|
| 746 | 746 | { |
| 747 | 747 | case 'seconds': |
| 748 | - $duration += (integer)$value; |
|
| 748 | + $duration += (integer) $value; |
|
| 749 | 749 | break; |
| 750 | 750 | case 'minutes': |
| 751 | - $duration += 60 * (integer)$value; |
|
| 751 | + $duration += 60 * (integer) $value; |
|
| 752 | 752 | break; |
| 753 | 753 | case 'hours': |
| 754 | - $duration += 3600 * (integer)$value; |
|
| 754 | + $duration += 3600 * (integer) $value; |
|
| 755 | 755 | break; |
| 756 | 756 | case 'days': |
| 757 | - $duration += 86400 * (integer)$value; |
|
| 757 | + $duration += 86400 * (integer) $value; |
|
| 758 | 758 | break; |
| 759 | 759 | case 'duration': |
| 760 | - $duration = (integer)$value; |
|
| 760 | + $duration = (integer) $value; |
|
| 761 | 761 | break 2; // switch, foreach |
| 762 | 762 | } |
| 763 | 763 | } |
@@ -770,15 +770,15 @@ discard block |
||
| 770 | 770 | * @param SimpleXmlElement parent node. |
| 771 | 771 | * @param SimpleXmlElement flush node. |
| 772 | 772 | */ |
| 773 | - protected function loadFlushOnCache($cacheModel,$parent,$node) |
|
| 773 | + protected function loadFlushOnCache($cacheModel, $parent, $node) |
|
| 774 | 774 | { |
| 775 | 775 | $id = $cacheModel->getID(); |
| 776 | - if(!isset($this->_FlushOnExecuteStatements[$id])) |
|
| 776 | + if (!isset($this->_FlushOnExecuteStatements[$id])) |
|
| 777 | 777 | $this->_FlushOnExecuteStatements[$id] = array(); |
| 778 | - foreach($node->attributes() as $name=>$value) |
|
| 778 | + foreach ($node->attributes() as $name=>$value) |
|
| 779 | 779 | { |
| 780 | - if(strtolower($name)==='statement') |
|
| 781 | - $this->_FlushOnExecuteStatements[$id][] = (string)$value; |
|
| 780 | + if (strtolower($name) === 'statement') |
|
| 781 | + $this->_FlushOnExecuteStatements[$id][] = (string) $value; |
|
| 782 | 782 | } |
| 783 | 783 | } |
| 784 | 784 | |
@@ -787,10 +787,10 @@ discard block |
||
| 787 | 787 | */ |
| 788 | 788 | protected function registerCacheTriggers() |
| 789 | 789 | { |
| 790 | - foreach($this->_FlushOnExecuteStatements as $cacheID => $statementIDs) |
|
| 790 | + foreach ($this->_FlushOnExecuteStatements as $cacheID => $statementIDs) |
|
| 791 | 791 | { |
| 792 | 792 | $cacheModel = $this->_manager->getCacheModel($cacheID); |
| 793 | - foreach($statementIDs as $statementID) |
|
| 793 | + foreach ($statementIDs as $statementID) |
|
| 794 | 794 | { |
| 795 | 795 | $statement = $this->_manager->getMappedStatement($statementID); |
| 796 | 796 | $cacheModel->registerTriggerStatement($statement); |
@@ -51,12 +51,13 @@ discard block |
||
| 51 | 51 | { |
| 52 | 52 | if(!in_array($name,$except)) |
| 53 | 53 | { |
| 54 | - if($obj->canSetProperty($name)) |
|
| 55 | - $obj->{$name} = (string)$value; |
|
| 56 | - else |
|
| 57 | - throw new TSqlMapConfigurationException( |
|
| 54 | + if($obj->canSetProperty($name)) { |
|
| 55 | + $obj->{$name} = (string)$value; |
|
| 56 | + } else { |
|
| 57 | + throw new TSqlMapConfigurationException( |
|
| 58 | 58 | 'sqlmap_invalid_property', $name, get_class($obj), |
| 59 | 59 | $node, $this->getConfigFile()); |
| 60 | + } |
|
| 60 | 61 | } |
| 61 | 62 | } |
| 62 | 63 | } |
@@ -71,13 +72,15 @@ discard block |
||
| 71 | 72 | { |
| 72 | 73 | $basedir = dirname($basefile); |
| 73 | 74 | $file = realpath($basedir.DIRECTORY_SEPARATOR.$resource); |
| 74 | - if(!is_string($file) || !is_file($file)) |
|
| 75 | - $file = realpath($resource); |
|
| 76 | - if(is_string($file) && is_file($file)) |
|
| 77 | - return $file; |
|
| 78 | - else |
|
| 79 | - throw new TSqlMapConfigurationException( |
|
| 75 | + if(!is_string($file) || !is_file($file)) { |
|
| 76 | + $file = realpath($resource); |
|
| 77 | + } |
|
| 78 | + if(is_string($file) && is_file($file)) { |
|
| 79 | + return $file; |
|
| 80 | + } else { |
|
| 81 | + throw new TSqlMapConfigurationException( |
|
| 80 | 82 | 'sqlmap_unable_to_find_resource', $resource); |
| 83 | + } |
|
| 81 | 84 | } |
| 82 | 85 | |
| 83 | 86 | /** |
@@ -87,12 +90,14 @@ discard block |
||
| 87 | 90 | */ |
| 88 | 91 | protected function loadXmlDocument($filename,TSqlMapXmlConfiguration $config) |
| 89 | 92 | { |
| 90 | - if( strpos($filename, '${') !== false) |
|
| 91 | - $filename = $config->replaceProperties($filename); |
|
| 93 | + if( strpos($filename, '${') !== false) { |
|
| 94 | + $filename = $config->replaceProperties($filename); |
|
| 95 | + } |
|
| 92 | 96 | |
| 93 | - if(!is_file($filename)) |
|
| 94 | - throw new TSqlMapConfigurationException( |
|
| 97 | + if(!is_file($filename)) { |
|
| 98 | + throw new TSqlMapConfigurationException( |
|
| 95 | 99 | 'sqlmap_unable_to_find_config', $filename); |
| 100 | + } |
|
| 96 | 101 | return simplexml_load_string($config->replaceProperties(file_get_contents($filename))); |
| 97 | 102 | } |
| 98 | 103 | |
@@ -109,8 +114,9 @@ discard block |
||
| 109 | 114 | foreach(array('id','ID','Id', 'iD') as $id) |
| 110 | 115 | { |
| 111 | 116 | $xpath = "//{$tag}[@{$id}='{$value}']"; |
| 112 | - foreach($document->xpath($xpath) as $node) |
|
| 113 | - return $node; |
|
| 117 | + foreach($document->xpath($xpath) as $node) { |
|
| 118 | + return $node; |
|
| 119 | + } |
|
| 114 | 120 | } |
| 115 | 121 | } |
| 116 | 122 | |
@@ -171,21 +177,25 @@ discard block |
||
| 171 | 177 | $this->_configFile=$filename; |
| 172 | 178 | $document = $this->loadXmlDocument($filename,$this); |
| 173 | 179 | |
| 174 | - foreach($document->xpath('//property') as $property) |
|
| 175 | - $this->loadGlobalProperty($property); |
|
| 180 | + foreach($document->xpath('//property') as $property) { |
|
| 181 | + $this->loadGlobalProperty($property); |
|
| 182 | + } |
|
| 176 | 183 | |
| 177 | - foreach($document->xpath('//typeHandler') as $handler) |
|
| 178 | - $this->loadTypeHandler($handler); |
|
| 184 | + foreach($document->xpath('//typeHandler') as $handler) { |
|
| 185 | + $this->loadTypeHandler($handler); |
|
| 186 | + } |
|
| 179 | 187 | |
| 180 | - foreach($document->xpath('//connection[last()]') as $conn) |
|
| 181 | - $this->loadDatabaseConnection($conn); |
|
| 188 | + foreach($document->xpath('//connection[last()]') as $conn) { |
|
| 189 | + $this->loadDatabaseConnection($conn); |
|
| 190 | + } |
|
| 182 | 191 | |
| 183 | 192 | //try to load configuration in the current config file. |
| 184 | 193 | $mapping = new TSqlMapXmlMappingConfiguration($this); |
| 185 | 194 | $mapping->configure($filename); |
| 186 | 195 | |
| 187 | - foreach($document->xpath('//sqlMap') as $sqlmap) |
|
| 188 | - $this->loadSqlMappingFiles($sqlmap); |
|
| 196 | + foreach($document->xpath('//sqlMap') as $sqlmap) { |
|
| 197 | + $this->loadSqlMappingFiles($sqlmap); |
|
| 198 | + } |
|
| 189 | 199 | |
| 190 | 200 | $this->resolveResultMapping(); |
| 191 | 201 | $this->attachCacheModels(); |
@@ -228,8 +238,9 @@ discard block |
||
| 228 | 238 | { |
| 229 | 239 | if(strlen($resource = (string)$node['resource']) > 0) |
| 230 | 240 | { |
| 231 | - if( strpos($resource, '${') !== false) |
|
| 232 | - $resource = $this->replaceProperties($resource); |
|
| 241 | + if( strpos($resource, '${') !== false) { |
|
| 242 | + $resource = $this->replaceProperties($resource); |
|
| 243 | + } |
|
| 233 | 244 | |
| 234 | 245 | $mapping = new TSqlMapXmlMappingConfiguration($this); |
| 235 | 246 | $filename = $this->getAbsoluteFilePath($this->_configFile, $resource); |
@@ -250,16 +261,18 @@ discard block |
||
| 250 | 261 | $resultMap = $item->getResultMapping(); |
| 251 | 262 | if(strlen($resultMap) > 0) |
| 252 | 263 | { |
| 253 | - if($maps->contains($resultMap)) |
|
| 254 | - $item->setNestedResultMap($maps[$resultMap]); |
|
| 255 | - else |
|
| 256 | - throw new TSqlMapConfigurationException( |
|
| 264 | + if($maps->contains($resultMap)) { |
|
| 265 | + $item->setNestedResultMap($maps[$resultMap]); |
|
| 266 | + } else { |
|
| 267 | + throw new TSqlMapConfigurationException( |
|
| 257 | 268 | 'sqlmap_unable_to_find_result_mapping', |
| 258 | 269 | $resultMap, $this->_configFile, $entry->getID()); |
| 270 | + } |
|
| 259 | 271 | } |
| 260 | 272 | } |
| 261 | - if($entry->getDiscriminator()!==null) |
|
| 262 | - $entry->getDiscriminator()->initialize($this->_manager); |
|
| 273 | + if($entry->getDiscriminator()!==null) { |
|
| 274 | + $entry->getDiscriminator()->initialize($this->_manager); |
|
| 275 | + } |
|
| 263 | 276 | } |
| 264 | 277 | } |
| 265 | 278 | |
@@ -286,8 +299,9 @@ discard block |
||
| 286 | 299 | */ |
| 287 | 300 | public function replaceProperties($string) |
| 288 | 301 | { |
| 289 | - foreach($this->_properties as $find => $replace) |
|
| 290 | - $string = str_replace('${'.$find.'}', $replace, $string); |
|
| 302 | + foreach($this->_properties as $find => $replace) { |
|
| 303 | + $string = str_replace('${'.$find.'}', $replace, $string); |
|
| 304 | + } |
|
| 291 | 305 | return $string; |
| 292 | 306 | } |
| 293 | 307 | } |
@@ -346,40 +360,51 @@ discard block |
||
| 346 | 360 | $this->_document=$document; |
| 347 | 361 | |
| 348 | 362 | static $bCacheDependencies; |
| 349 | - if($bCacheDependencies === null) |
|
| 350 | - $bCacheDependencies = Prado::getApplication()->getMode() !== TApplicationMode::Performance; |
|
| 363 | + if($bCacheDependencies === null) { |
|
| 364 | + $bCacheDependencies = Prado::getApplication()->getMode() !== TApplicationMode::Performance; |
|
| 365 | + } |
|
| 351 | 366 | |
| 352 | - if($bCacheDependencies) |
|
| 353 | - $this->_manager->getCacheDependencies() |
|
| 367 | + if($bCacheDependencies) { |
|
| 368 | + $this->_manager->getCacheDependencies() |
|
| 354 | 369 | ->getDependencies() |
| 355 | 370 | ->add(new TFileCacheDependency($filename)); |
| 371 | + } |
|
| 356 | 372 | |
| 357 | - foreach($document->xpath('//resultMap') as $node) |
|
| 358 | - $this->loadResultMap($node); |
|
| 373 | + foreach($document->xpath('//resultMap') as $node) { |
|
| 374 | + $this->loadResultMap($node); |
|
| 375 | + } |
|
| 359 | 376 | |
| 360 | - foreach($document->xpath('//parameterMap') as $node) |
|
| 361 | - $this->loadParameterMap($node); |
|
| 377 | + foreach($document->xpath('//parameterMap') as $node) { |
|
| 378 | + $this->loadParameterMap($node); |
|
| 379 | + } |
|
| 362 | 380 | |
| 363 | - foreach($document->xpath('//statement') as $node) |
|
| 364 | - $this->loadStatementTag($node); |
|
| 381 | + foreach($document->xpath('//statement') as $node) { |
|
| 382 | + $this->loadStatementTag($node); |
|
| 383 | + } |
|
| 365 | 384 | |
| 366 | - foreach($document->xpath('//select') as $node) |
|
| 367 | - $this->loadSelectTag($node); |
|
| 385 | + foreach($document->xpath('//select') as $node) { |
|
| 386 | + $this->loadSelectTag($node); |
|
| 387 | + } |
|
| 368 | 388 | |
| 369 | - foreach($document->xpath('//insert') as $node) |
|
| 370 | - $this->loadInsertTag($node); |
|
| 389 | + foreach($document->xpath('//insert') as $node) { |
|
| 390 | + $this->loadInsertTag($node); |
|
| 391 | + } |
|
| 371 | 392 | |
| 372 | - foreach($document->xpath('//update') as $node) |
|
| 373 | - $this->loadUpdateTag($node); |
|
| 393 | + foreach($document->xpath('//update') as $node) { |
|
| 394 | + $this->loadUpdateTag($node); |
|
| 395 | + } |
|
| 374 | 396 | |
| 375 | - foreach($document->xpath('//delete') as $node) |
|
| 376 | - $this->loadDeleteTag($node); |
|
| 397 | + foreach($document->xpath('//delete') as $node) { |
|
| 398 | + $this->loadDeleteTag($node); |
|
| 399 | + } |
|
| 377 | 400 | |
| 378 | - foreach($document->xpath('//procedure') as $node) |
|
| 379 | - $this->loadProcedureTag($node); |
|
| 401 | + foreach($document->xpath('//procedure') as $node) { |
|
| 402 | + $this->loadProcedureTag($node); |
|
| 403 | + } |
|
| 380 | 404 | |
| 381 | - foreach($document->xpath('//cacheModel') as $node) |
|
| 382 | - $this->loadCacheModel($node); |
|
| 405 | + foreach($document->xpath('//cacheModel') as $node) { |
|
| 406 | + $this->loadCacheModel($node); |
|
| 407 | + } |
|
| 383 | 408 | |
| 384 | 409 | $this->registerCacheTriggers(); |
| 385 | 410 | } |
@@ -398,21 +423,24 @@ discard block |
||
| 398 | 423 | if(!$this->_manager->getResultMaps()->contains($extendMap)) |
| 399 | 424 | { |
| 400 | 425 | $extendNode=$this->getElementByIdValue($this->_document,'resultMap',$extendMap); |
| 401 | - if($extendNode!==null) |
|
| 402 | - $this->loadResultMap($extendNode); |
|
| 426 | + if($extendNode!==null) { |
|
| 427 | + $this->loadResultMap($extendNode); |
|
| 428 | + } |
|
| 403 | 429 | } |
| 404 | 430 | |
| 405 | - if(!$this->_manager->getResultMaps()->contains($extendMap)) |
|
| 406 | - throw new TSqlMapConfigurationException( |
|
| 431 | + if(!$this->_manager->getResultMaps()->contains($extendMap)) { |
|
| 432 | + throw new TSqlMapConfigurationException( |
|
| 407 | 433 | 'sqlmap_unable_to_find_parent_result_map', $node, $this->_configFile, $extendMap); |
| 434 | + } |
|
| 408 | 435 | |
| 409 | 436 | $superMap = $this->_manager->getResultMap($extendMap); |
| 410 | 437 | $resultMap->getColumns()->mergeWith($superMap->getColumns()); |
| 411 | 438 | } |
| 412 | 439 | |
| 413 | 440 | //add the result map |
| 414 | - if(!$this->_manager->getResultMaps()->contains($resultMap->getID())) |
|
| 415 | - $this->_manager->addResultMap($resultMap); |
|
| 441 | + if(!$this->_manager->getResultMaps()->contains($resultMap->getID())) { |
|
| 442 | + $this->_manager->addResultMap($resultMap); |
|
| 443 | + } |
|
| 416 | 444 | } |
| 417 | 445 | |
| 418 | 446 | /** |
@@ -445,16 +473,18 @@ discard block |
||
| 445 | 473 | |
| 446 | 474 | foreach($node->xpath('subMap') as $subMapNode) |
| 447 | 475 | { |
| 448 | - if($discriminator===null) |
|
| 449 | - throw new TSqlMapConfigurationException( |
|
| 476 | + if($discriminator===null) { |
|
| 477 | + throw new TSqlMapConfigurationException( |
|
| 450 | 478 | 'sqlmap_undefined_discriminator', $node, $this->_configFile,$subMapNode); |
| 479 | + } |
|
| 451 | 480 | $subMap = new TSubMap; |
| 452 | 481 | $this->setObjectPropFromNode($subMap,$subMapNode); |
| 453 | 482 | $discriminator->addSubMap($subMap); |
| 454 | 483 | } |
| 455 | 484 | |
| 456 | - if($discriminator!==null) |
|
| 457 | - $resultMap->setDiscriminator($discriminator); |
|
| 485 | + if($discriminator!==null) { |
|
| 486 | + $resultMap->setDiscriminator($discriminator); |
|
| 487 | + } |
|
| 458 | 488 | |
| 459 | 489 | return $resultMap; |
| 460 | 490 | } |
@@ -473,17 +503,20 @@ discard block |
||
| 473 | 503 | if(!$this->_manager->getParameterMaps()->contains($extendMap)) |
| 474 | 504 | { |
| 475 | 505 | $extendNode=$this->getElementByIdValue($this->_document,'parameterMap',$extendMap); |
| 476 | - if($extendNode!==null) |
|
| 477 | - $this->loadParameterMap($extendNode); |
|
| 506 | + if($extendNode!==null) { |
|
| 507 | + $this->loadParameterMap($extendNode); |
|
| 508 | + } |
|
| 478 | 509 | } |
| 479 | 510 | |
| 480 | - if(!$this->_manager->getParameterMaps()->contains($extendMap)) |
|
| 481 | - throw new TSqlMapConfigurationException( |
|
| 511 | + if(!$this->_manager->getParameterMaps()->contains($extendMap)) { |
|
| 512 | + throw new TSqlMapConfigurationException( |
|
| 482 | 513 | 'sqlmap_unable_to_find_parent_parameter_map', $node, $this->_configFile,$extendMap); |
| 514 | + } |
|
| 483 | 515 | $superMap = $this->_manager->getParameterMap($extendMap); |
| 484 | 516 | $index = 0; |
| 485 | - foreach($superMap->getPropertyNames() as $propertyName) |
|
| 486 | - $parameterMap->insertProperty($index++,$superMap->getProperty($propertyName)); |
|
| 517 | + foreach($superMap->getPropertyNames() as $propertyName) { |
|
| 518 | + $parameterMap->insertProperty($index++,$superMap->getProperty($propertyName)); |
|
| 519 | + } |
|
| 487 | 520 | } |
| 488 | 521 | $this->_manager->addParameterMap($parameterMap); |
| 489 | 522 | } |
@@ -531,11 +564,12 @@ discard block |
||
| 531 | 564 | if(strlen($extend = $statement->getExtends()) > 0) |
| 532 | 565 | { |
| 533 | 566 | $superNode = $this->getElementByIdValue($this->_document,'*',$extend); |
| 534 | - if($superNode!==null) |
|
| 535 | - $commandText = (string)$superNode . $commandText; |
|
| 536 | - else |
|
| 537 | - throw new TSqlMapConfigurationException( |
|
| 567 | + if($superNode!==null) { |
|
| 568 | + $commandText = (string)$superNode . $commandText; |
|
| 569 | + } else { |
|
| 570 | + throw new TSqlMapConfigurationException( |
|
| 538 | 571 | 'sqlmap_unable_to_find_parent_sql', $extend, $this->_configFile,$node); |
| 572 | + } |
|
| 539 | 573 | } |
| 540 | 574 | //$commandText = $this->_xmlConfig->replaceProperties($commandText); |
| 541 | 575 | $statement->initialize($this->_manager); |
@@ -565,8 +599,9 @@ discard block |
||
| 565 | 599 | $map = new TParameterMap(); |
| 566 | 600 | $map->setID($statement->getID().'-InLineParameterMap'); |
| 567 | 601 | $statement->setInlineParameterMap($map); |
| 568 | - foreach($sqlText['parameters'] as $property) |
|
| 569 | - $map->addProperty($property); |
|
| 602 | + foreach($sqlText['parameters'] as $property) { |
|
| 603 | + $map->addProperty($property); |
|
| 604 | + } |
|
| 570 | 605 | } |
| 571 | 606 | $sqlStatement = $sqlText['sql']; |
| 572 | 607 | } |
@@ -591,9 +626,9 @@ discard block |
||
| 591 | 626 | { |
| 592 | 627 | $sql = new TSimpleDynamicSql($dynamics['parameters']); |
| 593 | 628 | $sqlStatement = $dynamics['sql']; |
| 629 | + } else { |
|
| 630 | + $sql = new TStaticSql(); |
|
| 594 | 631 | } |
| 595 | - else |
|
| 596 | - $sql = new TStaticSql(); |
|
| 597 | 632 | $sqlStatement=preg_replace('/'.self::SIMPLE_PLACEHOLDER.'/',self::SIMPLE_MARK,$sqlStatement); |
| 598 | 633 | $sql->buildPreparedStatement($statement, $sqlStatement); |
| 599 | 634 | $statement->setSqlText($sql); |
@@ -609,8 +644,9 @@ discard block |
||
| 609 | 644 | $this->setObjectPropFromNode($select,$node); |
| 610 | 645 | $this->processSqlStatement($select,$node); |
| 611 | 646 | $mappedStatement = new TMappedStatement($this->_manager, $select); |
| 612 | - if(strlen($select->getCacheModel()) > 0) |
|
| 613 | - $mappedStatement = new TCachingStatement($mappedStatement); |
|
| 647 | + if(strlen($select->getCacheModel()) > 0) { |
|
| 648 | + $mappedStatement = new TCachingStatement($mappedStatement); |
|
| 649 | + } |
|
| 614 | 650 | |
| 615 | 651 | $this->_manager->addMappedStatement($mappedStatement); |
| 616 | 652 | } |
@@ -636,8 +672,9 @@ discard block |
||
| 636 | 672 | { |
| 637 | 673 | $insert = new TSqlMapInsert; |
| 638 | 674 | $this->setObjectPropFromNode($insert,$node); |
| 639 | - if(isset($node->selectKey)) |
|
| 640 | - $this->loadSelectKeyTag($insert,$node->selectKey); |
|
| 675 | + if(isset($node->selectKey)) { |
|
| 676 | + $this->loadSelectKeyTag($insert,$node->selectKey); |
|
| 677 | + } |
|
| 641 | 678 | return $insert; |
| 642 | 679 | } |
| 643 | 680 | |
@@ -703,8 +740,9 @@ discard block |
||
| 703 | 740 | $properties = array('id','implementation'); |
| 704 | 741 | foreach($node->attributes() as $name=>$value) |
| 705 | 742 | { |
| 706 | - if(in_array(strtolower($name), $properties)) |
|
| 707 | - $cacheModel->{'set'.$name}((string)$value); |
|
| 743 | + if(in_array(strtolower($name), $properties)) { |
|
| 744 | + $cacheModel->{'set'.$name}((string)$value); |
|
| 745 | + } |
|
| 708 | 746 | } |
| 709 | 747 | $cache = Prado::createComponent($cacheModel->getImplementationClass(), $cacheModel); |
| 710 | 748 | $this->setObjectPropFromNode($cache,$node,$properties); |
@@ -712,12 +750,18 @@ discard block |
||
| 712 | 750 | foreach($node->xpath('property') as $propertyNode) |
| 713 | 751 | { |
| 714 | 752 | $name = $propertyNode->attributes()->name; |
| 715 | - if($name===null || $name==='') continue; |
|
| 753 | + if($name===null || $name==='') { |
|
| 754 | + continue; |
|
| 755 | + } |
|
| 716 | 756 | |
| 717 | 757 | $value = $propertyNode->attributes()->value; |
| 718 | - if($value===null || $value==='') continue; |
|
| 758 | + if($value===null || $value==='') { |
|
| 759 | + continue; |
|
| 760 | + } |
|
| 719 | 761 | |
| 720 | - if( !TPropertyAccess::has($cache, $name) ) continue; |
|
| 762 | + if( !TPropertyAccess::has($cache, $name) ) { |
|
| 763 | + continue; |
|
| 764 | + } |
|
| 721 | 765 | |
| 722 | 766 | TPropertyAccess::set($cache, $name, $value); |
| 723 | 767 | } |
@@ -726,8 +770,9 @@ discard block |
||
| 726 | 770 | |
| 727 | 771 | $cacheModel->initialize($cache); |
| 728 | 772 | $this->_manager->addCacheModel($cacheModel); |
| 729 | - foreach($node->xpath('flushOnExecute') as $flush) |
|
| 730 | - $this->loadFlushOnCache($cacheModel,$node,$flush); |
|
| 773 | + foreach($node->xpath('flushOnExecute') as $flush) { |
|
| 774 | + $this->loadFlushOnCache($cacheModel,$node,$flush); |
|
| 775 | + } |
|
| 731 | 776 | } |
| 732 | 777 | |
| 733 | 778 | /** |
@@ -738,7 +783,9 @@ discard block |
||
| 738 | 783 | protected function loadFlushInterval($cacheModel, $node) |
| 739 | 784 | { |
| 740 | 785 | $flushInterval = $node->xpath('flushInterval'); |
| 741 | - if($flushInterval === null || count($flushInterval) === 0) return; |
|
| 786 | + if($flushInterval === null || count($flushInterval) === 0) { |
|
| 787 | + return; |
|
| 788 | + } |
|
| 742 | 789 | $duration = 0; |
| 743 | 790 | foreach($flushInterval[0]->attributes() as $name=>$value) |
| 744 | 791 | { |
@@ -773,12 +820,14 @@ discard block |
||
| 773 | 820 | protected function loadFlushOnCache($cacheModel,$parent,$node) |
| 774 | 821 | { |
| 775 | 822 | $id = $cacheModel->getID(); |
| 776 | - if(!isset($this->_FlushOnExecuteStatements[$id])) |
|
| 777 | - $this->_FlushOnExecuteStatements[$id] = array(); |
|
| 823 | + if(!isset($this->_FlushOnExecuteStatements[$id])) { |
|
| 824 | + $this->_FlushOnExecuteStatements[$id] = array(); |
|
| 825 | + } |
|
| 778 | 826 | foreach($node->attributes() as $name=>$value) |
| 779 | 827 | { |
| 780 | - if(strtolower($name)==='statement') |
|
| 781 | - $this->_FlushOnExecuteStatements[$id][] = (string)$value; |
|
| 828 | + if(strtolower($name)==='statement') { |
|
| 829 | + $this->_FlushOnExecuteStatements[$id][] = (string)$value; |
|
| 830 | + } |
|
| 782 | 831 | } |
| 783 | 832 | } |
| 784 | 833 | |
@@ -116,6 +116,7 @@ |
||
| 116 | 116 | /** |
| 117 | 117 | * @param object handler to method calls. |
| 118 | 118 | * @param object the object to by proxied. |
| 119 | + * @param TLazyLoadList $handler |
|
| 119 | 120 | */ |
| 120 | 121 | public function __construct($handler, $object) |
| 121 | 122 | { |
@@ -20,9 +20,9 @@ discard block |
||
| 20 | 20 | { |
| 21 | 21 | private $_param; |
| 22 | 22 | private $_target; |
| 23 | - private $_propertyName=''; |
|
| 24 | - private $_statement=''; |
|
| 25 | - private $_loaded=false; |
|
| 23 | + private $_propertyName = ''; |
|
| 24 | + private $_statement = ''; |
|
| 25 | + private $_loaded = false; |
|
| 26 | 26 | private $_innerList; |
| 27 | 27 | private $_connection; |
| 28 | 28 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | $this->_param = $param; |
| 40 | 40 | $this->_target = $target; |
| 41 | 41 | $this->_statement = $mappedStatement; |
| 42 | - $this->_connection=$mappedStatement->getManager()->getDbConnection(); |
|
| 42 | + $this->_connection = $mappedStatement->getManager()->getDbConnection(); |
|
| 43 | 43 | $this->_propertyName = $propertyName; |
| 44 | 44 | } |
| 45 | 45 | |
@@ -55,10 +55,10 @@ discard block |
||
| 55 | 55 | { |
| 56 | 56 | $handler = new self($mappedStatement, $param, $target, $propertyName); |
| 57 | 57 | $statement = $mappedStatement->getStatement(); |
| 58 | - $registry=$mappedStatement->getManager()->getTypeHandlers(); |
|
| 58 | + $registry = $mappedStatement->getManager()->getTypeHandlers(); |
|
| 59 | 59 | $list = $statement->createInstanceOfListClass($registry); |
| 60 | - if(!is_object($list)) |
|
| 61 | - throw new TSqlMapExecutionException('sqlmap_invalid_lazyload_list',$statement->getID()); |
|
| 60 | + if (!is_object($list)) |
|
| 61 | + throw new TSqlMapExecutionException('sqlmap_invalid_lazyload_list', $statement->getID()); |
|
| 62 | 62 | return new TObjectProxy($handler, $list); |
| 63 | 63 | } |
| 64 | 64 | |
@@ -77,9 +77,9 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | protected function fetchListData() |
| 79 | 79 | { |
| 80 | - if($this->_loaded == false) |
|
| 80 | + if ($this->_loaded == false) |
|
| 81 | 81 | { |
| 82 | - $this->_innerList = $this->_statement->executeQueryForList($this->_connection,$this->_param); |
|
| 82 | + $this->_innerList = $this->_statement->executeQueryForList($this->_connection, $this->_param); |
|
| 83 | 83 | $this->_loaded = true; |
| 84 | 84 | //replace the target property with real list |
| 85 | 85 | TPropertyAccess::set($this->_target, $this->_propertyName, $this->_innerList); |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | public function hasMethod($method) |
| 95 | 95 | { |
| 96 | 96 | $this->fetchListData(); |
| 97 | - if(is_object($this->_innerList)) |
|
| 97 | + if (is_object($this->_innerList)) |
|
| 98 | 98 | return in_array($method, get_class_methods($this->_innerList)); |
| 99 | 99 | return false; |
| 100 | 100 | } |
@@ -130,9 +130,9 @@ discard block |
||
| 130 | 130 | * @param array method arguments |
| 131 | 131 | * @return mixed method return value. |
| 132 | 132 | */ |
| 133 | - public function __call($method,$params) |
|
| 133 | + public function __call($method, $params) |
|
| 134 | 134 | { |
| 135 | - if($this->_handler->hasMethod($method)) |
|
| 135 | + if ($this->_handler->hasMethod($method)) |
|
| 136 | 136 | return $this->_handler->intercept($method, $params); |
| 137 | 137 | else |
| 138 | 138 | return call_user_func_array(array($this->_object, $method), $params); |
@@ -57,8 +57,9 @@ discard block |
||
| 57 | 57 | $statement = $mappedStatement->getStatement(); |
| 58 | 58 | $registry=$mappedStatement->getManager()->getTypeHandlers(); |
| 59 | 59 | $list = $statement->createInstanceOfListClass($registry); |
| 60 | - if(!is_object($list)) |
|
| 61 | - throw new TSqlMapExecutionException('sqlmap_invalid_lazyload_list',$statement->getID()); |
|
| 60 | + if(!is_object($list)) { |
|
| 61 | + throw new TSqlMapExecutionException('sqlmap_invalid_lazyload_list',$statement->getID()); |
|
| 62 | + } |
|
| 62 | 63 | return new TObjectProxy($handler, $list); |
| 63 | 64 | } |
| 64 | 65 | |
@@ -94,8 +95,9 @@ discard block |
||
| 94 | 95 | public function hasMethod($method) |
| 95 | 96 | { |
| 96 | 97 | $this->fetchListData(); |
| 97 | - if(is_object($this->_innerList)) |
|
| 98 | - return in_array($method, get_class_methods($this->_innerList)); |
|
| 98 | + if(is_object($this->_innerList)) { |
|
| 99 | + return in_array($method, get_class_methods($this->_innerList)); |
|
| 100 | + } |
|
| 99 | 101 | return false; |
| 100 | 102 | } |
| 101 | 103 | } |
@@ -132,10 +134,11 @@ discard block |
||
| 132 | 134 | */ |
| 133 | 135 | public function __call($method,$params) |
| 134 | 136 | { |
| 135 | - if($this->_handler->hasMethod($method)) |
|
| 136 | - return $this->_handler->intercept($method, $params); |
|
| 137 | - else |
|
| 138 | - return call_user_func_array(array($this->_object, $method), $params); |
|
| 137 | + if($this->_handler->hasMethod($method)) { |
|
| 138 | + return $this->_handler->intercept($method, $params); |
|
| 139 | + } else { |
|
| 140 | + return call_user_func_array(array($this->_object, $method), $params); |
|
| 141 | + } |
|
| 139 | 142 | } |
| 140 | 143 | } |
| 141 | 144 | |
@@ -28,6 +28,7 @@ discard block |
||
| 28 | 28 | /** |
| 29 | 29 | * Create a new cache with limited cache size. |
| 30 | 30 | * @param TSqlMapCacheModel $cacheModel. |
| 31 | + * @param integer $cacheModel |
|
| 31 | 32 | */ |
| 32 | 33 | public function __construct($cacheModel=null) |
| 33 | 34 | { |
@@ -93,6 +94,7 @@ discard block |
||
| 93 | 94 | class TSqlMapFifoCache extends TSqlMapCache |
| 94 | 95 | { |
| 95 | 96 | /** |
| 97 | + * @param string $key |
|
| 96 | 98 | * @return mixed Gets a cached object with the specified key. |
| 97 | 99 | */ |
| 98 | 100 | public function get($key) |
@@ -105,6 +107,8 @@ discard block |
||
| 105 | 107 | * The expire and dependency parameters are ignored. |
| 106 | 108 | * @param string cache key |
| 107 | 109 | * @param mixed value to cache. |
| 110 | + * @param string $key |
|
| 111 | + * @param TComponent $value |
|
| 108 | 112 | */ |
| 109 | 113 | public function set($key, $value,$expire=0,$dependency=null) |
| 110 | 114 | { |
@@ -129,6 +133,7 @@ discard block |
||
| 129 | 133 | class TSqlMapLruCache extends TSqlMapCache |
| 130 | 134 | { |
| 131 | 135 | /** |
| 136 | + * @param string $key |
|
| 132 | 137 | * @return mixed Gets a cached object with the specified key. |
| 133 | 138 | */ |
| 134 | 139 | public function get($key) |
@@ -146,6 +151,8 @@ discard block |
||
| 146 | 151 | * The expire and dependency parameters are ignored. |
| 147 | 152 | * @param string the key identifying the value to be cached |
| 148 | 153 | * @param mixed the value to be cached |
| 154 | + * @param string $key |
|
| 155 | + * @param TComponent $value |
|
| 149 | 156 | */ |
| 150 | 157 | public function set($key, $value,$expire=0,$dependency=null) |
| 151 | 158 | { |
@@ -205,6 +212,9 @@ discard block |
||
| 205 | 212 | return $keyList; |
| 206 | 213 | } |
| 207 | 214 | |
| 215 | + /** |
|
| 216 | + * @param TList $keyList |
|
| 217 | + */ |
|
| 208 | 218 | protected function setKeyList($keyList) |
| 209 | 219 | { |
| 210 | 220 | $this->getCache()->set($this->getKeyListId(), $keyList); |
@@ -29,11 +29,11 @@ discard block |
||
| 29 | 29 | * Create a new cache with limited cache size. |
| 30 | 30 | * @param TSqlMapCacheModel $cacheModel. |
| 31 | 31 | */ |
| 32 | - public function __construct($cacheModel=null) |
|
| 32 | + public function __construct($cacheModel = null) |
|
| 33 | 33 | { |
| 34 | 34 | $this->_cache = new TMap; |
| 35 | 35 | $this->_keyList = new TList; |
| 36 | - $this->_cacheModel=$cacheModel; |
|
| 36 | + $this->_cacheModel = $cacheModel; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | public function setCacheSize($value) |
| 44 | 44 | { |
| 45 | - $this->_cacheSize=TPropertyValue::ensureInteger($value,100); |
|
| 45 | + $this->_cacheSize = TPropertyValue::ensureInteger($value, 100); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | /** |
| 77 | 77 | * @throws TSqlMapException not implemented. |
| 78 | 78 | */ |
| 79 | - public function add($id,$value,$expire=0,$dependency=null) |
|
| 79 | + public function add($id, $value, $expire = 0, $dependency = null) |
|
| 80 | 80 | { |
| 81 | 81 | throw new TSqlMapException('sqlmap_use_set_to_store_cache'); |
| 82 | 82 | } |
@@ -106,11 +106,11 @@ discard block |
||
| 106 | 106 | * @param string cache key |
| 107 | 107 | * @param mixed value to cache. |
| 108 | 108 | */ |
| 109 | - public function set($key, $value,$expire=0,$dependency=null) |
|
| 109 | + public function set($key, $value, $expire = 0, $dependency = null) |
|
| 110 | 110 | { |
| 111 | 111 | $this->_cache->add($key, $value); |
| 112 | 112 | $this->_keyList->add($key); |
| 113 | - if($this->_keyList->getCount() > $this->_cacheSize) |
|
| 113 | + if ($this->_keyList->getCount() > $this->_cacheSize) |
|
| 114 | 114 | { |
| 115 | 115 | $oldestKey = $this->_keyList->removeAt(0); |
| 116 | 116 | $this->_cache->remove($oldestKey); |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | */ |
| 134 | 134 | public function get($key) |
| 135 | 135 | { |
| 136 | - if($this->_keyList->contains($key)) |
|
| 136 | + if ($this->_keyList->contains($key)) |
|
| 137 | 137 | { |
| 138 | 138 | $this->_keyList->remove($key); |
| 139 | 139 | $this->_keyList->add($key); |
@@ -147,11 +147,11 @@ discard block |
||
| 147 | 147 | * @param string the key identifying the value to be cached |
| 148 | 148 | * @param mixed the value to be cached |
| 149 | 149 | */ |
| 150 | - public function set($key, $value,$expire=0,$dependency=null) |
|
| 150 | + public function set($key, $value, $expire = 0, $dependency = null) |
|
| 151 | 151 | { |
| 152 | 152 | $this->_cache->add($key, $value); |
| 153 | 153 | $this->_keyList->add($key); |
| 154 | - if($this->_keyList->getCount() > $this->_cacheSize) |
|
| 154 | + if ($this->_keyList->getCount() > $this->_cacheSize) |
|
| 155 | 155 | { |
| 156 | 156 | $oldestKey = $this->_keyList->removeAt(0); |
| 157 | 157 | $this->_cache->remove($oldestKey); |
@@ -169,15 +169,15 @@ discard block |
||
| 169 | 169 | */ |
| 170 | 170 | class TSqlMapApplicationCache implements ICache |
| 171 | 171 | { |
| 172 | - protected $_cacheModel=null; |
|
| 172 | + protected $_cacheModel = null; |
|
| 173 | 173 | |
| 174 | 174 | /** |
| 175 | 175 | * Create a new cache with limited cache size. |
| 176 | 176 | * @param TSqlMapCacheModel $cacheModel. |
| 177 | 177 | */ |
| 178 | - public function __construct($cacheModel=null) |
|
| 178 | + public function __construct($cacheModel = null) |
|
| 179 | 179 | { |
| 180 | - $this->_cacheModel=$cacheModel; |
|
| 180 | + $this->_cacheModel = $cacheModel; |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | /** |
@@ -186,9 +186,9 @@ discard block |
||
| 186 | 186 | */ |
| 187 | 187 | protected function getKeyListId() |
| 188 | 188 | { |
| 189 | - $id='keyList'; |
|
| 189 | + $id = 'keyList'; |
|
| 190 | 190 | if ($this->_cacheModel instanceof TSqlMapCacheModel) |
| 191 | - $id.='_'.$this->_cacheModel->getId(); |
|
| 191 | + $id .= '_' . $this->_cacheModel->getId(); |
|
| 192 | 192 | return $id; |
| 193 | 193 | } |
| 194 | 194 | /** |
@@ -197,9 +197,9 @@ discard block |
||
| 197 | 197 | */ |
| 198 | 198 | protected function getKeyList() |
| 199 | 199 | { |
| 200 | - if (($keyList=$this->getCache()->get($this->getKeyListId()))===false) |
|
| 200 | + if (($keyList = $this->getCache()->get($this->getKeyListId())) === false) |
|
| 201 | 201 | { |
| 202 | - $keyList=new TList(); |
|
| 202 | + $keyList = new TList(); |
|
| 203 | 203 | $this->getCache()->set($this->getKeyListId(), $keyList); |
| 204 | 204 | } |
| 205 | 205 | return $keyList; |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | */ |
| 216 | 216 | public function delete($key) |
| 217 | 217 | { |
| 218 | - $keyList=$this->getKeyList(); |
|
| 218 | + $keyList = $this->getKeyList(); |
|
| 219 | 219 | $keyList->remove($key); |
| 220 | 220 | $this->getCache()->delete($key); |
| 221 | 221 | $this->setKeyList($keyList); |
@@ -226,8 +226,8 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | public function flush() |
| 228 | 228 | { |
| 229 | - $keyList=$this->getKeyList(); |
|
| 230 | - $cache=$this->getCache(); |
|
| 229 | + $keyList = $this->getKeyList(); |
|
| 230 | + $cache = $this->getCache(); |
|
| 231 | 231 | foreach ($keyList as $key) |
| 232 | 232 | { |
| 233 | 233 | $cache->delete($key); |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | if ($result === false) |
| 246 | 246 | { |
| 247 | 247 | // if the key has not been found in cache (e.g expired), remove from keylist |
| 248 | - $keyList=$this->getKeyList(); |
|
| 248 | + $keyList = $this->getKeyList(); |
|
| 249 | 249 | if ($keyList->contains($key)) |
| 250 | 250 | { |
| 251 | 251 | $keyList->remove($key); |
@@ -260,10 +260,10 @@ discard block |
||
| 260 | 260 | * @param string the key identifying the value to be cached |
| 261 | 261 | * @param mixed the value to be cached |
| 262 | 262 | */ |
| 263 | - public function set($key, $value,$expire=0,$dependency=null) |
|
| 263 | + public function set($key, $value, $expire = 0, $dependency = null) |
|
| 264 | 264 | { |
| 265 | - $this->getCache()->set($key, $value, $expire,$dependency); |
|
| 266 | - $keyList=$this->getKeyList(); |
|
| 265 | + $this->getCache()->set($key, $value, $expire, $dependency); |
|
| 266 | + $keyList = $this->getKeyList(); |
|
| 267 | 267 | if (!$keyList->contains($key)) |
| 268 | 268 | { |
| 269 | 269 | $keyList->add($key); |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | /** |
| 283 | 283 | * @throws TSqlMapException not implemented. |
| 284 | 284 | */ |
| 285 | - public function add($id,$value,$expire=0,$dependency=null) |
|
| 285 | + public function add($id, $value, $expire = 0, $dependency = null) |
|
| 286 | 286 | { |
| 287 | 287 | throw new TSqlMapException('sqlmap_use_set_to_store_cache'); |
| 288 | 288 | } |
@@ -187,8 +187,9 @@ |
||
| 187 | 187 | protected function getKeyListId() |
| 188 | 188 | { |
| 189 | 189 | $id='keyList'; |
| 190 | - if ($this->_cacheModel instanceof TSqlMapCacheModel) |
|
| 191 | - $id.='_'.$this->_cacheModel->getId(); |
|
| 190 | + if ($this->_cacheModel instanceof TSqlMapCacheModel) { |
|
| 191 | + $id.='_'.$this->_cacheModel->getId(); |
|
| 192 | + } |
|
| 192 | 193 | return $id; |
| 193 | 194 | } |
| 194 | 195 | /** |
@@ -40,6 +40,7 @@ discard block |
||
| 40 | 40 | * @param int page size |
| 41 | 41 | * @param mixed delegate for each data row retrieved. |
| 42 | 42 | * @param int number of page to fetch on initialization |
| 43 | + * @param integer $pageSize |
|
| 43 | 44 | */ |
| 44 | 45 | public function __construct(IMappedStatement $statement,$parameter, $pageSize, $delegate=null, $page=0) |
| 45 | 46 | { |
@@ -55,6 +56,8 @@ discard block |
||
| 55 | 56 | * @param mixed query parameters |
| 56 | 57 | * @param int page size. |
| 57 | 58 | * @param int number of page. |
| 59 | + * @param IMappedStatement $statement |
|
| 60 | + * @param integer $page |
|
| 58 | 61 | */ |
| 59 | 62 | protected function initialize($statement, $parameter, $pageSize, $page) |
| 60 | 63 | { |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | private $_parameter; |
| 32 | 32 | private $_prevPageList; |
| 33 | 33 | private $_nextPageList; |
| 34 | - private $_delegate=null; |
|
| 34 | + private $_delegate = null; |
|
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * Create a new SqlMap paged list. |
@@ -41,12 +41,12 @@ discard block |
||
| 41 | 41 | * @param mixed delegate for each data row retrieved. |
| 42 | 42 | * @param int number of page to fetch on initialization |
| 43 | 43 | */ |
| 44 | - public function __construct(IMappedStatement $statement,$parameter, $pageSize, $delegate=null, $page=0) |
|
| 44 | + public function __construct(IMappedStatement $statement, $parameter, $pageSize, $delegate = null, $page = 0) |
|
| 45 | 45 | { |
| 46 | 46 | parent::__construct(); |
| 47 | 47 | parent::setCustomPaging(true); |
| 48 | - $this->initialize($statement,$parameter, $pageSize, $page); |
|
| 49 | - $this->_delegate=$delegate; |
|
| 48 | + $this->initialize($statement, $parameter, $pageSize, $page); |
|
| 49 | + $this->_delegate = $delegate; |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | { |
| 115 | 115 | $total = $data instanceof TList ? $data->getCount() : count($data); |
| 116 | 116 | $pageSize = $this->getPageSize(); |
| 117 | - if($total < 1) |
|
| 117 | + if ($total < 1) |
|
| 118 | 118 | { |
| 119 | 119 | $param->setData($data); |
| 120 | 120 | $this->_prevPageList = null; |
@@ -122,10 +122,10 @@ discard block |
||
| 122 | 122 | return; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - if($param->getNewPageIndex() < 1) |
|
| 125 | + if ($param->getNewPageIndex() < 1) |
|
| 126 | 126 | { |
| 127 | 127 | $this->_prevPageList = null; |
| 128 | - if($total <= $pageSize) |
|
| 128 | + if ($total <= $pageSize) |
|
| 129 | 129 | { |
| 130 | 130 | $param->setData($data); |
| 131 | 131 | $this->_nextPageList = null; |
@@ -133,18 +133,18 @@ discard block |
||
| 133 | 133 | else |
| 134 | 134 | { |
| 135 | 135 | $param->setData(array_slice($data, 0, $pageSize)); |
| 136 | - $this->_nextPageList = array_slice($data, $pageSize-1,$total); |
|
| 136 | + $this->_nextPageList = array_slice($data, $pageSize - 1, $total); |
|
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | else |
| 140 | 140 | { |
| 141 | - if($total <= $pageSize) |
|
| 141 | + if ($total <= $pageSize) |
|
| 142 | 142 | { |
| 143 | 143 | $this->_prevPageList = array_slice($data, 0, $total); |
| 144 | 144 | $param->setData(array()); |
| 145 | 145 | $this->_nextPageList = null; |
| 146 | 146 | } |
| 147 | - else if($total <= $pageSize*2) |
|
| 147 | + else if ($total <= $pageSize * 2) |
|
| 148 | 148 | { |
| 149 | 149 | $this->_prevPageList = array_slice($data, 0, $pageSize); |
| 150 | 150 | $param->setData(array_slice($data, $pageSize, $total)); |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | { |
| 155 | 155 | $this->_prevPageList = array_slice($data, 0, $pageSize); |
| 156 | 156 | $param->setData(array_slice($data, $pageSize, $pageSize)); |
| 157 | - $this->_nextPageList = array_slice($data, $pageSize*2, $total-$pageSize*2); |
|
| 157 | + $this->_nextPageList = array_slice($data, $pageSize * 2, $total - $pageSize * 2); |
|
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | } |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | { |
| 169 | 169 | $index = $param->getNewPageIndex(); |
| 170 | 170 | $pageSize = $this->getPageSize(); |
| 171 | - return $index < 1 ? array($index, $pageSize*2) : array(($index-1)*$pageSize, $pageSize*3); |
|
| 171 | + return $index < 1 ? array($index, $pageSize * 2) : array(($index - 1) * $pageSize, $pageSize * 3); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | /** |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | public function getIsNextPageAvailable() |
| 178 | 178 | { |
| 179 | - return $this->_nextPageList!==null; |
|
| 179 | + return $this->_nextPageList !== null; |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | public function getIsPreviousPageAvailable() |
| 186 | 186 | { |
| 187 | - return $this->_prevPageList!==null; |
|
| 187 | + return $this->_prevPageList !== null; |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | /** |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | */ |
| 193 | 193 | public function getIsLastPage() |
| 194 | 194 | { |
| 195 | - return ($this->_nextPageList===null) || $this->_nextPageList->getCount() < 1; |
|
| 195 | + return ($this->_nextPageList === null) || $this->_nextPageList->getCount() < 1; |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | /** |
@@ -129,28 +129,24 @@ |
||
| 129 | 129 | { |
| 130 | 130 | $param->setData($data); |
| 131 | 131 | $this->_nextPageList = null; |
| 132 | - } |
|
| 133 | - else |
|
| 132 | + } else |
|
| 134 | 133 | { |
| 135 | 134 | $param->setData(array_slice($data, 0, $pageSize)); |
| 136 | 135 | $this->_nextPageList = array_slice($data, $pageSize-1,$total); |
| 137 | 136 | } |
| 138 | - } |
|
| 139 | - else |
|
| 137 | + } else |
|
| 140 | 138 | { |
| 141 | 139 | if($total <= $pageSize) |
| 142 | 140 | { |
| 143 | 141 | $this->_prevPageList = array_slice($data, 0, $total); |
| 144 | 142 | $param->setData(array()); |
| 145 | 143 | $this->_nextPageList = null; |
| 146 | - } |
|
| 147 | - else if($total <= $pageSize*2) |
|
| 144 | + } else if($total <= $pageSize*2) |
|
| 148 | 145 | { |
| 149 | 146 | $this->_prevPageList = array_slice($data, 0, $pageSize); |
| 150 | 147 | $param->setData(array_slice($data, $pageSize, $total)); |
| 151 | 148 | $this->_nextPageList = null; |
| 152 | - } |
|
| 153 | - else |
|
| 149 | + } else |
|
| 154 | 150 | { |
| 155 | 151 | $this->_prevPageList = array_slice($data, 0, $pageSize); |
| 156 | 152 | $param->setData(array_slice($data, $pageSize, $pageSize)); |
@@ -40,6 +40,7 @@ discard block |
||
| 40 | 40 | * @param mixed The object used to set the parameters in the SQL. |
| 41 | 41 | * @param string The property of the result object to be used as the key. |
| 42 | 42 | * @param string The property of the result object to be used as the value (or null) |
| 43 | + * @param TDbConnection $connection |
|
| 43 | 44 | * @return TMap A map of object containing the rows keyed by <tt>$keyProperty</tt>. |
| 44 | 45 | */ |
| 45 | 46 | public function executeQueryForMap($connection, $parameter, $keyProperty, $valueProperty=null); |
@@ -50,6 +51,7 @@ discard block |
||
| 50 | 51 | * number of row effected. |
| 51 | 52 | * @param IDbConnection database connection to execute the query |
| 52 | 53 | * @param mixed The object used to set the parameters in the SQL. |
| 54 | + * @param TDbConnection $connection |
|
| 53 | 55 | * @return integer The number of row effected. |
| 54 | 56 | */ |
| 55 | 57 | public function executeUpdate($connection, $parameter); |
@@ -62,6 +64,7 @@ discard block |
||
| 62 | 64 | * @param TList A list to populate the result with. |
| 63 | 65 | * @param integer The number of rows to skip over. |
| 64 | 66 | * @param integer The maximum number of rows to return. |
| 67 | + * @param TDbConnection $connection |
|
| 65 | 68 | * @return TList A TList of result objects. |
| 66 | 69 | */ |
| 67 | 70 | public function executeQueryForList($connection, $parameter, $result=null, $skip=-1, $max=-1); |
@@ -73,6 +76,7 @@ discard block |
||
| 73 | 76 | * @param IDbConnection database connection to execute the query |
| 74 | 77 | * @param mixed The object used to set the parameters in the SQL. |
| 75 | 78 | * @param object The result object. |
| 79 | + * @param TDbConnection $connection |
|
| 76 | 80 | * @return object result. |
| 77 | 81 | */ |
| 78 | 82 | public function executeQueryForObject($connection,$parameter, $result=null); |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * @param string The property of the result object to be used as the value (or null) |
| 43 | 43 | * @return TMap A map of object containing the rows keyed by <tt>$keyProperty</tt>. |
| 44 | 44 | */ |
| 45 | - public function executeQueryForMap($connection, $parameter, $keyProperty, $valueProperty=null); |
|
| 45 | + public function executeQueryForMap($connection, $parameter, $keyProperty, $valueProperty = null); |
|
| 46 | 46 | |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * @param integer The maximum number of rows to return. |
| 65 | 65 | * @return TList A TList of result objects. |
| 66 | 66 | */ |
| 67 | - public function executeQueryForList($connection, $parameter, $result=null, $skip=-1, $max=-1); |
|
| 67 | + public function executeQueryForList($connection, $parameter, $result = null, $skip = -1, $max = -1); |
|
| 68 | 68 | |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -75,6 +75,6 @@ discard block |
||
| 75 | 75 | * @param object The result object. |
| 76 | 76 | * @return object result. |
| 77 | 77 | */ |
| 78 | - public function executeQueryForObject($connection,$parameter, $result=null); |
|
| 78 | + public function executeQueryForObject($connection, $parameter, $result = null); |
|
| 79 | 79 | } |
| 80 | 80 | |