@@ -94,12 +94,12 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | protected function collectForeignObjects(&$results) |
| 96 | 96 | { |
| 97 | - $fkeys = $this->getRelationForeignKeys(); |
|
| 98 | - $properties = array_values($fkeys); |
|
| 99 | - $fields = array_keys($fkeys); |
|
| 97 | + $fkeys=$this->getRelationForeignKeys(); |
|
| 98 | + $properties=array_values($fkeys); |
|
| 99 | + $fields=array_keys($fkeys); |
|
| 100 | 100 | |
| 101 | - $indexValues = $this->getIndexValues($properties, $results); |
|
| 102 | - $fkObjects = $this->findForeignObjects($fields, $indexValues); |
|
| 101 | + $indexValues=$this->getIndexValues($properties, $results); |
|
| 102 | + $fkObjects=$this->findForeignObjects($fields, $indexValues); |
|
| 103 | 103 | $this->populateResult($results, $properties, $fkObjects, $fields); |
| 104 | 104 | } |
| 105 | 105 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | public function getRelationForeignKeys() |
| 111 | 111 | { |
| 112 | - $fkObject = $this->getContext()->getForeignRecordFinder(); |
|
| 112 | + $fkObject=$this->getContext()->getForeignRecordFinder(); |
|
| 113 | 113 | return $this->findForeignKeys($fkObject, $this->getSourceRecord()); |
| 114 | 114 | } |
| 115 | 115 | |
@@ -120,8 +120,8 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | protected function setObjectProperty($source, $properties, &$collections) |
| 122 | 122 | { |
| 123 | - $hash = $this->getObjectHash($source, $properties); |
|
| 124 | - $prop = $this->getContext()->getProperty(); |
|
| 123 | + $hash=$this->getObjectHash($source, $properties); |
|
| 124 | + $prop=$this->getContext()->getProperty(); |
|
| 125 | 125 | if(isset($collections[$hash]) && count($collections[$hash]) > 0) |
| 126 | 126 | { |
| 127 | 127 | if(count($collections[$hash]) > 1) |
@@ -136,9 +136,9 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | public function updateAssociatedRecords() |
| 138 | 138 | { |
| 139 | - $fkObject = $this->getContext()->getPropertyValue(); |
|
| 140 | - $source = $this->getSourceRecord(); |
|
| 141 | - $fkeys = $this->findForeignKeys($fkObject, $source); |
|
| 139 | + $fkObject=$this->getContext()->getPropertyValue(); |
|
| 140 | + $source=$this->getSourceRecord(); |
|
| 141 | + $fkeys=$this->findForeignKeys($fkObject, $source); |
|
| 142 | 142 | foreach($fkeys as $fKey => $srcKey) |
| 143 | 143 | $fkObject->setColumnValue($fKey, $source->getColumnValue($srcKey)); |
| 144 | 144 | return $fkObject->save(); |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | protected function createDateControl($container, $column, $record) |
| 63 | 63 | { |
| 64 | - $control = parent::createDateControl($container, $column, $record); |
|
| 65 | - $value = $this->getRecordPropertyValue($column, $record); |
|
| 64 | + $control=parent::createDateControl($container, $column, $record); |
|
| 65 | + $value=$this->getRecordPropertyValue($column, $record); |
|
| 66 | 66 | if(!empty($value) && preg_match('/timestamp/i', $column->getDbType())) |
| 67 | 67 | $control->setTimestamp(intval($value)); |
| 68 | 68 | return $control; |
@@ -70,11 +70,11 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | protected function createDateTimeControl($container, $column, $record) |
| 72 | 72 | { |
| 73 | - $value = $this->getRecordPropertyValue($column, $record); |
|
| 74 | - $time = parent::createDateTimeControl($container, $column, $record); |
|
| 73 | + $value=$this->getRecordPropertyValue($column, $record); |
|
| 74 | + $time=parent::createDateTimeControl($container, $column, $record); |
|
| 75 | 75 | if(!empty($value) && preg_match('/timestamp/i', $column->getDbType())) |
| 76 | 76 | { |
| 77 | - $dt = new \DateTime; |
|
| 77 | + $dt=new \DateTime; |
|
| 78 | 78 | $dt->setTimestamp(intval($value)); |
| 79 | 79 | $time[1]->setSelectedValue($dt->format('G')); |
| 80 | 80 | $time[2]->setSelectedValue($dt->format('i')); |
@@ -87,12 +87,12 @@ discard block |
||
| 87 | 87 | { |
| 88 | 88 | if(preg_match('/timestamp/i', $column->getDbType())) |
| 89 | 89 | { |
| 90 | - $time = $container->findControl(self::DEFAULT_ID)->getTimestamp(); |
|
| 91 | - $dt = new \DateTime; |
|
| 90 | + $time=$container->findControl(self::DEFAULT_ID)->getTimestamp(); |
|
| 91 | + $dt=new \DateTime; |
|
| 92 | 92 | $dt->setTimestamp($time); |
| 93 | - $hour = $container->findControl('scaffold_time_hour')->getSelectedValue(); |
|
| 94 | - $mins = $container->findControl('scaffold_time_min')->getSelectedValue(); |
|
| 95 | - $secs = $container->findControl('scaffold_time_sec')->getSelectedValue(); |
|
| 93 | + $hour=$container->findControl('scaffold_time_hour')->getSelectedValue(); |
|
| 94 | + $mins=$container->findControl('scaffold_time_min')->getSelectedValue(); |
|
| 95 | + $secs=$container->findControl('scaffold_time_sec')->getSelectedValue(); |
|
| 96 | 96 | return $s->getTimeStamp( |
| 97 | 97 | $hour, |
| 98 | 98 | $mins, |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | public function __construct($object) |
| 31 | 31 | { |
| 32 | - $this->_key = $this->generateKey(serialize($object)); |
|
| 32 | + $this->_key=$this->generateKey(serialize($object)); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -56,25 +56,25 @@ discard block |
||
| 56 | 56 | { |
| 57 | 57 | if(!is_array($object) && !is_object($object)) |
| 58 | 58 | return $object; |
| 59 | - $properties = explode('.', $path); |
|
| 59 | + $properties=explode('.', $path); |
|
| 60 | 60 | foreach($properties as $prop) |
| 61 | 61 | { |
| 62 | 62 | if(is_array($object) || $object instanceof \ArrayAccess) |
| 63 | 63 | { |
| 64 | 64 | if(array_key_exists($prop, $object)) |
| 65 | - $object = $object[$prop]; |
|
| 65 | + $object=$object[$prop]; |
|
| 66 | 66 | else |
| 67 | 67 | throw new TInvalidPropertyException('sqlmap_invalid_property', $path); |
| 68 | 68 | } |
| 69 | 69 | elseif(is_object($object)) |
| 70 | 70 | { |
| 71 | - $getter = 'get' . $prop; |
|
| 71 | + $getter='get'.$prop; |
|
| 72 | 72 | if(method_exists($object, $getter) && is_callable([$object, $getter])) |
| 73 | - $object = $object->{$getter}(); |
|
| 73 | + $object=$object->{$getter}(); |
|
| 74 | 74 | elseif(in_array($prop, array_keys(get_object_vars($object)))) |
| 75 | - $object = $object->{$prop}; |
|
| 75 | + $object=$object->{$prop}; |
|
| 76 | 76 | elseif(method_exists($object, '__get') && is_callable([$object, '__get'])) |
| 77 | - $object = $object->{$prop}; |
|
| 77 | + $object=$object->{$prop}; |
|
| 78 | 78 | else |
| 79 | 79 | throw new TInvalidPropertyException('sqlmap_invalid_property', $path); |
| 80 | 80 | } |
@@ -93,25 +93,25 @@ discard block |
||
| 93 | 93 | { |
| 94 | 94 | if(!is_array($object) && !is_object($object)) |
| 95 | 95 | return false; |
| 96 | - $properties = explode('.', $path); |
|
| 96 | + $properties=explode('.', $path); |
|
| 97 | 97 | foreach($properties as $prop) |
| 98 | 98 | { |
| 99 | 99 | if(is_array($object) || $object instanceof \ArrayAccess) |
| 100 | 100 | { |
| 101 | 101 | if(array_key_exists($prop, $object)) |
| 102 | - $object = $object[$prop]; |
|
| 102 | + $object=$object[$prop]; |
|
| 103 | 103 | else |
| 104 | 104 | return false; |
| 105 | 105 | } |
| 106 | 106 | elseif(is_object($object)) |
| 107 | 107 | { |
| 108 | - $getter = 'get' . $prop; |
|
| 108 | + $getter='get'.$prop; |
|
| 109 | 109 | if(method_exists($object, $getter) && is_callable([$object, $getter])) |
| 110 | - $object = $object->{$getter}(); |
|
| 110 | + $object=$object->{$getter}(); |
|
| 111 | 111 | elseif(in_array($prop, array_keys(get_object_vars($object)))) |
| 112 | - $object = $object->{$prop}; |
|
| 112 | + $object=$object->{$prop}; |
|
| 113 | 113 | elseif(method_exists($object, '__get') && is_callable([$object, '__get'])) |
| 114 | - $object = $object->{$prop}; |
|
| 114 | + $object=$object->{$prop}; |
|
| 115 | 115 | else |
| 116 | 116 | return false; |
| 117 | 117 | } |
@@ -130,24 +130,24 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | public static function set(&$originalObject, $path, $value) |
| 132 | 132 | { |
| 133 | - $properties = explode('.', $path); |
|
| 134 | - $prop = array_pop($properties); |
|
| 133 | + $properties=explode('.', $path); |
|
| 134 | + $prop=array_pop($properties); |
|
| 135 | 135 | if(count($properties) > 0) |
| 136 | - $object = self::get($originalObject, implode('.', $properties)); |
|
| 136 | + $object=self::get($originalObject, implode('.', $properties)); |
|
| 137 | 137 | else |
| 138 | - $object = &$originalObject; |
|
| 138 | + $object=&$originalObject; |
|
| 139 | 139 | |
| 140 | 140 | if(is_array($object) || $object instanceof \ArrayAccess) |
| 141 | 141 | { |
| 142 | - $object[$prop] = $value; |
|
| 142 | + $object[$prop]=$value; |
|
| 143 | 143 | } |
| 144 | 144 | elseif(is_object($object)) |
| 145 | 145 | { |
| 146 | - $setter = 'set' . $prop; |
|
| 147 | - if (method_exists($object, $setter) && is_callable([$object, $setter])) |
|
| 146 | + $setter='set'.$prop; |
|
| 147 | + if(method_exists($object, $setter) && is_callable([$object, $setter])) |
|
| 148 | 148 | $object->{$setter}($value); |
| 149 | 149 | else |
| 150 | - $object->{$prop} = $value; |
|
| 150 | + $object->{$prop}=$value; |
|
| 151 | 151 | } |
| 152 | 152 | else |
| 153 | 153 | throw new TInvalidPropertyException('sqlmap_invalid_property_type', $path); |
@@ -30,8 +30,8 @@ |
||
| 30 | 30 | */ |
| 31 | 31 | public function __construct($handler, $object) |
| 32 | 32 | { |
| 33 | - $this->_handler = $handler; |
|
| 34 | - $this->_object = $object; |
|
| 33 | + $this->_handler=$handler; |
|
| 34 | + $this->_object=$object; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -66,7 +66,7 @@ |
||
| 66 | 66 | */ |
| 67 | 67 | public function setText($value) |
| 68 | 68 | { |
| 69 | - if(parent::getText() === $value) |
|
| 69 | + if(parent::getText()===$value) |
|
| 70 | 70 | return; |
| 71 | 71 | |
| 72 | 72 | parent::setText($value); |
@@ -36,9 +36,9 @@ discard block |
||
| 36 | 36 | class TComponentReflection extends \Prado\TComponent |
| 37 | 37 | { |
| 38 | 38 | private $_className; |
| 39 | - private $_properties = []; |
|
| 40 | - private $_events = []; |
|
| 41 | - private $_methods = []; |
|
| 39 | + private $_properties=[]; |
|
| 40 | + private $_events=[]; |
|
| 41 | + private $_methods=[]; |
|
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | 44 | * Constructor. |
@@ -48,9 +48,9 @@ discard block |
||
| 48 | 48 | public function __construct($component) |
| 49 | 49 | { |
| 50 | 50 | if(is_string($component) && class_exists($component, false)) |
| 51 | - $this->_className = $component; |
|
| 51 | + $this->_className=$component; |
|
| 52 | 52 | elseif(is_object($component)) |
| 53 | - $this->_className = get_class($component); |
|
| 53 | + $this->_className=get_class($component); |
|
| 54 | 54 | else |
| 55 | 55 | throw new TInvalidDataTypeException('componentreflection_class_invalid'); |
| 56 | 56 | $this->reflect(); |
@@ -58,74 +58,74 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | private function isPropertyMethod($method) |
| 60 | 60 | { |
| 61 | - $methodName = $method->getName(); |
|
| 62 | - return $method->getNumberOfRequiredParameters() === 0 |
|
| 63 | - && strncasecmp($methodName, 'get', 3) === 0 |
|
| 61 | + $methodName=$method->getName(); |
|
| 62 | + return $method->getNumberOfRequiredParameters()===0 |
|
| 63 | + && strncasecmp($methodName, 'get', 3)===0 |
|
| 64 | 64 | && isset($methodName[3]); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | private function isEventMethod($method) |
| 68 | 68 | { |
| 69 | - $methodName = $method->getName(); |
|
| 70 | - return strncasecmp($methodName, 'on', 2) === 0 |
|
| 69 | + $methodName=$method->getName(); |
|
| 70 | + return strncasecmp($methodName, 'on', 2)===0 |
|
| 71 | 71 | && isset($methodName[2]); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | private function reflect() |
| 75 | 75 | { |
| 76 | - $class = new \ReflectionClass($this->_className); |
|
| 77 | - $properties = []; |
|
| 78 | - $events = []; |
|
| 79 | - $methods = []; |
|
| 80 | - $isComponent = is_subclass_of($this->_className, 'TComponent') || strcasecmp($this->_className, 'TComponent') === 0; |
|
| 76 | + $class=new \ReflectionClass($this->_className); |
|
| 77 | + $properties=[]; |
|
| 78 | + $events=[]; |
|
| 79 | + $methods=[]; |
|
| 80 | + $isComponent=is_subclass_of($this->_className, 'TComponent') || strcasecmp($this->_className, 'TComponent')===0; |
|
| 81 | 81 | foreach($class->getMethods() as $method) |
| 82 | 82 | { |
| 83 | 83 | if($method->isPublic() || $method->isProtected()) |
| 84 | 84 | { |
| 85 | - $methodName = $method->getName(); |
|
| 85 | + $methodName=$method->getName(); |
|
| 86 | 86 | if(!$method->isStatic() && $isComponent) |
| 87 | 87 | { |
| 88 | 88 | if($this->isPropertyMethod($method)) |
| 89 | - $properties[substr($methodName, 3)] = $method; |
|
| 89 | + $properties[substr($methodName, 3)]=$method; |
|
| 90 | 90 | elseif($this->isEventMethod($method)) |
| 91 | 91 | { |
| 92 | - $methodName[0] = 'O'; |
|
| 93 | - $events[$methodName] = $method; |
|
| 92 | + $methodName[0]='O'; |
|
| 93 | + $events[$methodName]=$method; |
|
| 94 | 94 | } |
| 95 | 95 | } |
| 96 | - if(strncmp($methodName, '__', 2) !== 0) |
|
| 97 | - $methods[$methodName] = $method; |
|
| 96 | + if(strncmp($methodName, '__', 2)!==0) |
|
| 97 | + $methods[$methodName]=$method; |
|
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | - $reserved = []; |
|
| 100 | + $reserved=[]; |
|
| 101 | 101 | ksort($properties); |
| 102 | 102 | foreach($properties as $name => $method) |
| 103 | 103 | { |
| 104 | - $this->_properties[$name] = [ |
|
| 104 | + $this->_properties[$name]=[ |
|
| 105 | 105 | 'type' => $this->determinePropertyType($method), |
| 106 | - 'readonly' => !$class->hasMethod('set' . $name), |
|
| 106 | + 'readonly' => !$class->hasMethod('set'.$name), |
|
| 107 | 107 | 'protected' => $method->isProtected(), |
| 108 | 108 | 'class' => $method->getDeclaringClass()->getName(), |
| 109 | 109 | 'comments' => $method->getDocComment() |
| 110 | 110 | ]; |
| 111 | - $reserved['get' . strtolower($name)] = 1; |
|
| 112 | - $reserved['set' . strtolower($name)] = 1; |
|
| 111 | + $reserved['get'.strtolower($name)]=1; |
|
| 112 | + $reserved['set'.strtolower($name)]=1; |
|
| 113 | 113 | } |
| 114 | 114 | ksort($events); |
| 115 | 115 | foreach($events as $name => $method) |
| 116 | 116 | { |
| 117 | - $this->_events[$name] = [ |
|
| 117 | + $this->_events[$name]=[ |
|
| 118 | 118 | 'class' => $method->getDeclaringClass()->getName(), |
| 119 | 119 | 'protected' => $method->isProtected(), |
| 120 | 120 | 'comments' => $method->getDocComment() |
| 121 | 121 | ]; |
| 122 | - $reserved[strtolower($name)] = 1; |
|
| 122 | + $reserved[strtolower($name)]=1; |
|
| 123 | 123 | } |
| 124 | 124 | ksort($methods); |
| 125 | 125 | foreach($methods as $name => $method) |
| 126 | 126 | { |
| 127 | 127 | if(!isset($reserved[strtolower($name)])) |
| 128 | - $this->_methods[$name] = [ |
|
| 128 | + $this->_methods[$name]=[ |
|
| 129 | 129 | 'class' => $method->getDeclaringClass()->getName(), |
| 130 | 130 | 'protected' => $method->isProtected(), |
| 131 | 131 | 'static' => $method->isStatic(), |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | protected function determinePropertyType($method) |
| 144 | 144 | { |
| 145 | - $comment = $method->getDocComment(); |
|
| 145 | + $comment=$method->getDocComment(); |
|
| 146 | 146 | if(preg_match('/@return\\s+(.*?)\\s+/', $comment, $matches)) |
| 147 | 147 | return $matches[1]; |
| 148 | 148 | else |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | public function setFileName($value) |
| 52 | 52 | { |
| 53 | - $this->_fileName = $value; |
|
| 54 | - $this->_timestamp = @filemtime($value); |
|
| 53 | + $this->_fileName=$value; |
|
| 54 | + $this->_timestamp=@filemtime($value); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -69,6 +69,6 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | public function getHasChanged() |
| 71 | 71 | { |
| 72 | - return @filemtime($this->_fileName) !== $this->_timestamp; |
|
| 72 | + return @filemtime($this->_fileName)!==$this->_timestamp; |
|
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | \ No newline at end of file |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | /** |
| 96 | 96 | * @var string the ID of TDataSourceConfig module |
| 97 | 97 | */ |
| 98 | - private $_connID = ''; |
|
| 98 | + private $_connID=''; |
|
| 99 | 99 | /** |
| 100 | 100 | * @var TDbConnection the DB connection instance |
| 101 | 101 | */ |
@@ -103,26 +103,26 @@ discard block |
||
| 103 | 103 | /** |
| 104 | 104 | * @var string name of the DB cache table |
| 105 | 105 | */ |
| 106 | - private $_cacheTable = 'pradocache'; |
|
| 106 | + private $_cacheTable='pradocache'; |
|
| 107 | 107 | /** |
| 108 | 108 | * @var integer Interval expired items will be removed from cache |
| 109 | 109 | */ |
| 110 | - private $_flushInterval = 60; |
|
| 110 | + private $_flushInterval=60; |
|
| 111 | 111 | /** |
| 112 | 112 | * @var boolean |
| 113 | 113 | */ |
| 114 | - private $_cacheInitialized = false; |
|
| 114 | + private $_cacheInitialized=false; |
|
| 115 | 115 | /** |
| 116 | 116 | * @var boolean |
| 117 | 117 | */ |
| 118 | - private $_createCheck = false; |
|
| 118 | + private $_createCheck=false; |
|
| 119 | 119 | /** |
| 120 | 120 | * @var boolean whether the cache DB table should be created automatically |
| 121 | 121 | */ |
| 122 | - private $_autoCreate = true; |
|
| 123 | - private $_username = ''; |
|
| 124 | - private $_password = ''; |
|
| 125 | - private $_connectionString = ''; |
|
| 122 | + private $_autoCreate=true; |
|
| 123 | + private $_username=''; |
|
| 124 | + private $_password=''; |
|
| 125 | + private $_connectionString=''; |
|
| 126 | 126 | |
| 127 | 127 | /** |
| 128 | 128 | * Destructor. |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | public function __destruct() |
| 132 | 132 | { |
| 133 | - if($this->_db !== null) |
|
| 133 | + if($this->_db!==null) |
|
| 134 | 134 | $this->_db->setActive(false); |
| 135 | 135 | } |
| 136 | 136 | |
@@ -183,26 +183,26 @@ discard block |
||
| 183 | 183 | * @throws TConfigurationException if any error happens during creating database or cache table. |
| 184 | 184 | * @since 3.1.5 |
| 185 | 185 | */ |
| 186 | - protected function initializeCache($force = false) |
|
| 186 | + protected function initializeCache($force=false) |
|
| 187 | 187 | { |
| 188 | 188 | if($this->_cacheInitialized && !$force) return; |
| 189 | - $db = $this->getDbConnection(); |
|
| 189 | + $db=$this->getDbConnection(); |
|
| 190 | 190 | try |
| 191 | 191 | { |
| 192 | - $key = 'TDbCache:' . $this->_cacheTable . ':created'; |
|
| 192 | + $key='TDbCache:'.$this->_cacheTable.':created'; |
|
| 193 | 193 | if($force) |
| 194 | - $this -> _createCheck = false; |
|
| 194 | + $this -> _createCheck=false; |
|
| 195 | 195 | else |
| 196 | - $this -> _createCheck = $this -> getApplication() -> getGlobalState($key, 0); |
|
| 196 | + $this -> _createCheck=$this -> getApplication() -> getGlobalState($key, 0); |
|
| 197 | 197 | |
| 198 | 198 | if($this->_autoCreate && !$this -> _createCheck) { |
| 199 | 199 | |
| 200 | - Prado::trace(($force ? 'Force initializing: ' : 'Initializing: ') . $this -> id . ', ' . $this->_cacheTable, '\Prado\Caching\TDbCache'); |
|
| 200 | + Prado::trace(($force ? 'Force initializing: ' : 'Initializing: ').$this -> id.', '.$this->_cacheTable, '\Prado\Caching\TDbCache'); |
|
| 201 | 201 | |
| 202 | - $sql = 'SELECT 1 FROM ' . $this->_cacheTable . ' WHERE 0=1'; |
|
| 202 | + $sql='SELECT 1 FROM '.$this->_cacheTable.' WHERE 0=1'; |
|
| 203 | 203 | $db->createCommand($sql)->queryScalar(); |
| 204 | 204 | |
| 205 | - $this -> _createCheck = true; |
|
| 205 | + $this -> _createCheck=true; |
|
| 206 | 206 | $this -> getApplication() -> setGlobalState($key, time()); |
| 207 | 207 | } |
| 208 | 208 | } |
@@ -211,29 +211,29 @@ discard block |
||
| 211 | 211 | // DB table not exists |
| 212 | 212 | if($this->_autoCreate) |
| 213 | 213 | { |
| 214 | - Prado::trace('Autocreate: ' . $this->_cacheTable, '\Prado\Caching\TDbCache'); |
|
| 214 | + Prado::trace('Autocreate: '.$this->_cacheTable, '\Prado\Caching\TDbCache'); |
|
| 215 | 215 | |
| 216 | - $driver = $db->getDriverName(); |
|
| 217 | - if($driver === 'mysql') |
|
| 218 | - $blob = 'LONGBLOB'; |
|
| 219 | - elseif($driver === 'pgsql') |
|
| 220 | - $blob = 'BYTEA'; |
|
| 216 | + $driver=$db->getDriverName(); |
|
| 217 | + if($driver==='mysql') |
|
| 218 | + $blob='LONGBLOB'; |
|
| 219 | + elseif($driver==='pgsql') |
|
| 220 | + $blob='BYTEA'; |
|
| 221 | 221 | else |
| 222 | - $blob = 'BLOB'; |
|
| 222 | + $blob='BLOB'; |
|
| 223 | 223 | |
| 224 | - $sql = 'CREATE TABLE ' . $this->_cacheTable . " (itemkey CHAR(128) PRIMARY KEY, value $blob, expire INTEGER)"; |
|
| 224 | + $sql='CREATE TABLE '.$this->_cacheTable." (itemkey CHAR(128) PRIMARY KEY, value $blob, expire INTEGER)"; |
|
| 225 | 225 | $db->createCommand($sql)->execute(); |
| 226 | 226 | |
| 227 | - $sql = 'CREATE INDEX IX_expire ON ' . $this->_cacheTable . ' (expire)'; |
|
| 227 | + $sql='CREATE INDEX IX_expire ON '.$this->_cacheTable.' (expire)'; |
|
| 228 | 228 | $db->createCommand($sql)->execute(); |
| 229 | 229 | |
| 230 | - $this -> _createCheck = true; |
|
| 230 | + $this -> _createCheck=true; |
|
| 231 | 231 | $this -> getApplication() -> setGlobalState($key, time()); |
| 232 | 232 | } |
| 233 | 233 | else |
| 234 | 234 | throw new TConfigurationException('db_cachetable_inexistent', $this->_cacheTable); |
| 235 | 235 | } |
| 236 | - $this->_cacheInitialized = true; |
|
| 236 | + $this->_cacheInitialized=true; |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | /** |
@@ -242,20 +242,20 @@ discard block |
||
| 242 | 242 | * @return void |
| 243 | 243 | * @since 3.1.5 |
| 244 | 244 | */ |
| 245 | - public function flushCacheExpired($force = false) |
|
| 245 | + public function flushCacheExpired($force=false) |
|
| 246 | 246 | { |
| 247 | - $interval = $this -> getFlushInterval(); |
|
| 248 | - if(!$force && $interval === 0) return; |
|
| 247 | + $interval=$this -> getFlushInterval(); |
|
| 248 | + if(!$force && $interval===0) return; |
|
| 249 | 249 | |
| 250 | - $key = 'TDbCache:' . $this->_cacheTable . ':flushed'; |
|
| 251 | - $now = time(); |
|
| 252 | - $next = $interval + (integer)$this -> getApplication() -> getGlobalState($key, 0); |
|
| 250 | + $key='TDbCache:'.$this->_cacheTable.':flushed'; |
|
| 251 | + $now=time(); |
|
| 252 | + $next=$interval + (integer) $this -> getApplication() -> getGlobalState($key, 0); |
|
| 253 | 253 | |
| 254 | 254 | if($force || $next <= $now) |
| 255 | 255 | { |
| 256 | 256 | if(!$this->_cacheInitialized) $this->initializeCache(); |
| 257 | - Prado::trace(($force ? 'Force flush of expired items: ' : 'Flush expired items: ') . $this -> id . ', ' . $this->_cacheTable, '\Prado\Caching\TDbCache'); |
|
| 258 | - $sql = 'DELETE FROM ' . $this->_cacheTable . ' WHERE expire<>0 AND expire<' . $now; |
|
| 257 | + Prado::trace(($force ? 'Force flush of expired items: ' : 'Flush expired items: ').$this -> id.', '.$this->_cacheTable, '\Prado\Caching\TDbCache'); |
|
| 258 | + $sql='DELETE FROM '.$this->_cacheTable.' WHERE expire<>0 AND expire<'.$now; |
|
| 259 | 259 | $this->getDbConnection()->createCommand($sql)->execute(); |
| 260 | 260 | $this -> getApplication() -> setGlobalState($key, $now); |
| 261 | 261 | } |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | */ |
| 282 | 282 | public function setFlushInterval($value) |
| 283 | 283 | { |
| 284 | - $this->_flushInterval = (integer) $value; |
|
| 284 | + $this->_flushInterval=(integer) $value; |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | /** |
@@ -292,9 +292,9 @@ discard block |
||
| 292 | 292 | */ |
| 293 | 293 | protected function createDbConnection() |
| 294 | 294 | { |
| 295 | - if($this->_connID !== '') |
|
| 295 | + if($this->_connID!=='') |
|
| 296 | 296 | { |
| 297 | - $config = $this->getApplication()->getModule($this->_connID); |
|
| 297 | + $config=$this->getApplication()->getModule($this->_connID); |
|
| 298 | 298 | if($config instanceof TDataSourceConfig) |
| 299 | 299 | return $config->getDbConnection(); |
| 300 | 300 | else |
@@ -302,20 +302,20 @@ discard block |
||
| 302 | 302 | } |
| 303 | 303 | else |
| 304 | 304 | { |
| 305 | - $db = new TDbConnection; |
|
| 306 | - if($this->_connectionString !== '') |
|
| 305 | + $db=new TDbConnection; |
|
| 306 | + if($this->_connectionString!=='') |
|
| 307 | 307 | { |
| 308 | 308 | $db->setConnectionString($this->_connectionString); |
| 309 | - if($this->_username !== '') |
|
| 309 | + if($this->_username!=='') |
|
| 310 | 310 | $db->setUsername($this->_username); |
| 311 | - if($this->_password !== '') |
|
| 311 | + if($this->_password!=='') |
|
| 312 | 312 | $db->setPassword($this->_password); |
| 313 | 313 | } |
| 314 | 314 | else |
| 315 | 315 | { |
| 316 | 316 | // default to SQLite3 database |
| 317 | - $dbFile = $this->getApplication()->getRuntimePath() . '/sqlite3.cache'; |
|
| 318 | - $db->setConnectionString('sqlite:' . $dbFile); |
|
| 317 | + $dbFile=$this->getApplication()->getRuntimePath().'/sqlite3.cache'; |
|
| 318 | + $db->setConnectionString('sqlite:'.$dbFile); |
|
| 319 | 319 | } |
| 320 | 320 | return $db; |
| 321 | 321 | } |
@@ -326,8 +326,8 @@ discard block |
||
| 326 | 326 | */ |
| 327 | 327 | public function getDbConnection() |
| 328 | 328 | { |
| 329 | - if($this->_db === null) |
|
| 330 | - $this->_db = $this->createDbConnection(); |
|
| 329 | + if($this->_db===null) |
|
| 330 | + $this->_db=$this->createDbConnection(); |
|
| 331 | 331 | |
| 332 | 332 | $this->_db->setActive(true); |
| 333 | 333 | return $this->_db; |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | */ |
| 353 | 353 | public function setConnectionID($value) |
| 354 | 354 | { |
| 355 | - $this->_connID = $value; |
|
| 355 | + $this->_connID=$value; |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | /** |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | */ |
| 370 | 370 | public function setConnectionString($value) |
| 371 | 371 | { |
| 372 | - $this->_connectionString = $value; |
|
| 372 | + $this->_connectionString=$value; |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | /** |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | */ |
| 386 | 386 | public function setUsername($value) |
| 387 | 387 | { |
| 388 | - $this->_username = $value; |
|
| 388 | + $this->_username=$value; |
|
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | /** |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | */ |
| 402 | 402 | public function setPassword($value) |
| 403 | 403 | { |
| 404 | - $this->_password = $value; |
|
| 404 | + $this->_password=$value; |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | /** |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | */ |
| 435 | 435 | public function setCacheTableName($value) |
| 436 | 436 | { |
| 437 | - $this->_cacheTable = $value; |
|
| 437 | + $this->_cacheTable=$value; |
|
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | /** |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | */ |
| 453 | 453 | public function setAutoCreateCacheTable($value) |
| 454 | 454 | { |
| 455 | - $this->_autoCreate = TPropertyValue::ensureBoolean($value); |
|
| 455 | + $this->_autoCreate=TPropertyValue::ensureBoolean($value); |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | /** |
@@ -465,8 +465,8 @@ discard block |
||
| 465 | 465 | { |
| 466 | 466 | if(!$this->_cacheInitialized) $this->initializeCache(); |
| 467 | 467 | try { |
| 468 | - $sql = 'SELECT value FROM ' . $this->_cacheTable . ' WHERE itemkey=\'' . $key . '\' AND (expire=0 OR expire>' . time() . ') ORDER BY expire DESC'; |
|
| 469 | - $command = $this->getDbConnection()->createCommand($sql); |
|
| 468 | + $sql='SELECT value FROM '.$this->_cacheTable.' WHERE itemkey=\''.$key.'\' AND (expire=0 OR expire>'.time().') ORDER BY expire DESC'; |
|
| 469 | + $command=$this->getDbConnection()->createCommand($sql); |
|
| 470 | 470 | return unserialize($command->queryScalar()); |
| 471 | 471 | } |
| 472 | 472 | catch(\Exception $e) |
@@ -503,11 +503,11 @@ discard block |
||
| 503 | 503 | protected function addValue($key, $value, $expire) |
| 504 | 504 | { |
| 505 | 505 | if(!$this->_cacheInitialized) $this->initializeCache(); |
| 506 | - $expire = ($expire <= 0)?0:time() + $expire; |
|
| 507 | - $sql = "INSERT INTO {$this->_cacheTable} (itemkey,value,expire) VALUES(:key,:value,$expire)"; |
|
| 506 | + $expire=($expire <= 0) ? 0 : time() + $expire; |
|
| 507 | + $sql="INSERT INTO {$this->_cacheTable} (itemkey,value,expire) VALUES(:key,:value,$expire)"; |
|
| 508 | 508 | try |
| 509 | 509 | { |
| 510 | - $command = $this->getDbConnection()->createCommand($sql); |
|
| 510 | + $command=$this->getDbConnection()->createCommand($sql); |
|
| 511 | 511 | $command->bindValue(':key', $key, \PDO::PARAM_STR); |
| 512 | 512 | $command->bindValue(':value', serialize($value), \PDO::PARAM_LOB); |
| 513 | 513 | $command->execute(); |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | if(!$this->_cacheInitialized) $this->initializeCache(); |
| 540 | 540 | try |
| 541 | 541 | { |
| 542 | - $command = $this->getDbConnection()->createCommand("DELETE FROM {$this->_cacheTable} WHERE itemkey=:key"); |
|
| 542 | + $command=$this->getDbConnection()->createCommand("DELETE FROM {$this->_cacheTable} WHERE itemkey=:key"); |
|
| 543 | 543 | $command->bindValue(':key', $key, \PDO::PARAM_STR); |
| 544 | 544 | $command->execute(); |
| 545 | 545 | return true; |
@@ -561,7 +561,7 @@ discard block |
||
| 561 | 561 | if(!$this->_cacheInitialized) $this->initializeCache(); |
| 562 | 562 | try |
| 563 | 563 | { |
| 564 | - $command = $this->getDbConnection()->createCommand("DELETE FROM {$this->_cacheTable}"); |
|
| 564 | + $command=$this->getDbConnection()->createCommand("DELETE FROM {$this->_cacheTable}"); |
|
| 565 | 565 | $command->execute(); |
| 566 | 566 | } |
| 567 | 567 | catch(\Exception $e) |