@@ -22,33 +22,33 @@ |
||
22 | 22 | private $_parameterNames; |
23 | 23 | private $_parameterValues; |
24 | 24 | |
25 | - public function getPreparedSql(){ return $this->_sqlString; } |
|
26 | - public function setPreparedSql($value){ $this->_sqlString = $value; } |
|
25 | + public function getPreparedSql() { return $this->_sqlString; } |
|
26 | + public function setPreparedSql($value) { $this->_sqlString=$value; } |
|
27 | 27 | |
28 | - public function getParameterNames($needed = true) |
|
28 | + public function getParameterNames($needed=true) |
|
29 | 29 | { |
30 | - if (!$this->_parameterNames and $needed) |
|
31 | - $this->_parameterNames = new TList; |
|
30 | + if(!$this->_parameterNames and $needed) |
|
31 | + $this->_parameterNames=new TList; |
|
32 | 32 | return $this->_parameterNames; |
33 | 33 | } |
34 | 34 | |
35 | - public function setParameterNames($value){ $this->_parameterNames = $value; } |
|
35 | + public function setParameterNames($value) { $this->_parameterNames=$value; } |
|
36 | 36 | |
37 | - public function getParameterValues($needed = true) |
|
37 | + public function getParameterValues($needed=true) |
|
38 | 38 | { |
39 | - if (!$this->_parameterValues and $needed) |
|
39 | + if(!$this->_parameterValues and $needed) |
|
40 | 40 | $this->_parameterValues=new TMap; |
41 | 41 | return $this->_parameterValues; |
42 | 42 | } |
43 | 43 | |
44 | - public function setParameterValues($value){ $this->_parameterValues = $value; } |
|
44 | + public function setParameterValues($value) { $this->_parameterValues=$value; } |
|
45 | 45 | |
46 | 46 | public function __sleep() |
47 | 47 | { |
48 | - $exprops = array(); $cn = __CLASS__; |
|
49 | - if (!$this->_parameterNames or !$this->_parameterNames->getCount()) $exprops[] = "\0$cn\0_parameterNames"; |
|
50 | - if (!$this->_parameterValues or !$this->_parameterValues->getCount()) $exprops[] = "\0$cn\0_parameterValues"; |
|
51 | - return array_diff(parent::__sleep(),$exprops); |
|
48 | + $exprops=array(); $cn=__CLASS__; |
|
49 | + if(!$this->_parameterNames or !$this->_parameterNames->getCount()) $exprops[]="\0$cn\0_parameterNames"; |
|
50 | + if(!$this->_parameterValues or !$this->_parameterValues->getCount()) $exprops[]="\0$cn\0_parameterValues"; |
|
51 | + return array_diff(parent::__sleep(), $exprops); |
|
52 | 52 | } |
53 | 53 | } |
54 | 54 |
@@ -21,45 +21,45 @@ |
||
21 | 21 | */ |
22 | 22 | class TPreparedCommand |
23 | 23 | { |
24 | - public function create(TSqlMapManager $manager, $connection, $statement, $parameterObject,$skip=null,$max=null) |
|
24 | + public function create(TSqlMapManager $manager, $connection, $statement, $parameterObject, $skip=null, $max=null) |
|
25 | 25 | { |
26 | - $sqlText = $statement->getSQLText(); |
|
26 | + $sqlText=$statement->getSQLText(); |
|
27 | 27 | |
28 | - $prepared = $sqlText->getPreparedStatement($parameterObject); |
|
28 | + $prepared=$sqlText->getPreparedStatement($parameterObject); |
|
29 | 29 | $connection->setActive(true); |
30 | - $sql = $prepared->getPreparedSql(); |
|
30 | + $sql=$prepared->getPreparedSql(); |
|
31 | 31 | |
32 | 32 | if($sqlText instanceof TSimpleDynamicSql) |
33 | - $sql = $sqlText->replaceDynamicParameter($sql, $parameterObject); |
|
33 | + $sql=$sqlText->replaceDynamicParameter($sql, $parameterObject); |
|
34 | 34 | |
35 | 35 | if($max!==null || $skip!==null) |
36 | 36 | { |
37 | - $builder = TDbMetaData::getInstance($connection)->createCommandBuilder(); |
|
38 | - $sql = $builder->applyLimitOffset($sql,$max,$skip); |
|
37 | + $builder=TDbMetaData::getInstance($connection)->createCommandBuilder(); |
|
38 | + $sql=$builder->applyLimitOffset($sql, $max, $skip); |
|
39 | 39 | } |
40 | - $command = $connection->createCommand($sql); |
|
40 | + $command=$connection->createCommand($sql); |
|
41 | 41 | $this->applyParameterMap($manager, $command, $prepared, $statement, $parameterObject); |
42 | 42 | |
43 | 43 | return $command; |
44 | 44 | } |
45 | 45 | |
46 | - protected function applyParameterMap($manager,$command,$prepared, $statement, $parameterObject) |
|
46 | + protected function applyParameterMap($manager, $command, $prepared, $statement, $parameterObject) |
|
47 | 47 | { |
48 | - $properties = $prepared->getParameterNames(false); |
|
48 | + $properties=$prepared->getParameterNames(false); |
|
49 | 49 | //$parameters = $prepared->getParameterValues(); |
50 | 50 | $registry=$manager->getTypeHandlers(); |
51 | - if ($properties) |
|
52 | - for($i = 0, $k=$properties->getCount(); $i<$k; $i++) |
|
51 | + if($properties) |
|
52 | + for($i=0, $k=$properties->getCount(); $i < $k; $i++) |
|
53 | 53 | { |
54 | - $property = $statement->parameterMap()->getProperty($i); |
|
55 | - $value = $statement->parameterMap()->getPropertyValue($registry,$property, $parameterObject); |
|
56 | - $dbType = $property->getDbType(); |
|
54 | + $property=$statement->parameterMap()->getProperty($i); |
|
55 | + $value=$statement->parameterMap()->getPropertyValue($registry, $property, $parameterObject); |
|
56 | + $dbType=$property->getDbType(); |
|
57 | 57 | if($dbType=='') //relies on PHP lax comparison |
58 | - $command->bindValue($i+1,$value, TDbCommandBuilder::getPdoType($value)); |
|
58 | + $command->bindValue($i + 1, $value, TDbCommandBuilder::getPdoType($value)); |
|
59 | 59 | else if(strpos($dbType, 'PDO::')===0) |
60 | - $command->bindValue($i+1,$value, constant($property->getDbType())); //assumes PDO types, e.g. PDO::PARAM_INT |
|
60 | + $command->bindValue($i + 1, $value, constant($property->getDbType())); //assumes PDO types, e.g. PDO::PARAM_INT |
|
61 | 61 | else |
62 | - $command->bindValue($i+1,$value); |
|
62 | + $command->bindValue($i + 1, $value); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | } |
@@ -22,8 +22,8 @@ |
||
22 | 22 | |
23 | 23 | public function buildPreparedStatement($statement, $sqlString) |
24 | 24 | { |
25 | - $factory = new TPreparedStatementFactory($statement, $sqlString); |
|
26 | - $this->_preparedStatement = $factory->prepare(); |
|
25 | + $factory=new TPreparedStatementFactory($statement, $sqlString); |
|
26 | + $this->_preparedStatement=$factory->prepare(); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | public function getPreparedStatement($parameter=null) |
@@ -22,8 +22,8 @@ discard block |
||
22 | 22 | { |
23 | 23 | protected $_keyList; |
24 | 24 | protected $_cache; |
25 | - protected $_cacheSize = 100; |
|
26 | - protected $_cacheModel = null; |
|
25 | + protected $_cacheSize=100; |
|
26 | + protected $_cacheModel=null; |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Create a new cache with limited cache size. |
@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function __construct($cacheModel=null) |
33 | 33 | { |
34 | - $this->_cache = new TMap; |
|
35 | - $this->_keyList = new TList; |
|
34 | + $this->_cache=new TMap; |
|
35 | + $this->_keyList=new TList; |
|
36 | 36 | $this->_cacheModel=$cacheModel; |
37 | 37 | } |
38 | 38 | |
@@ -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 | /** |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function delete($key) |
60 | 60 | { |
61 | - $object = $this->get($key); |
|
61 | + $object=$this->get($key); |
|
62 | 62 | $this->_cache->remove($key); |
63 | 63 | $this->_keyList->remove($key); |
64 | 64 | return $object; |
@@ -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,13 +106,13 @@ 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 | 113 | if($this->_keyList->getCount() > $this->_cacheSize) |
114 | 114 | { |
115 | - $oldestKey = $this->_keyList->removeAt(0); |
|
115 | + $oldestKey=$this->_keyList->removeAt(0); |
|
116 | 116 | $this->_cache->remove($oldestKey); |
117 | 117 | } |
118 | 118 | } |
@@ -147,13 +147,13 @@ 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 | 154 | if($this->_keyList->getCount() > $this->_cacheSize) |
155 | 155 | { |
156 | - $oldestKey = $this->_keyList->removeAt(0); |
|
156 | + $oldestKey=$this->_keyList->removeAt(0); |
|
157 | 157 | $this->_cache->remove($oldestKey); |
158 | 158 | } |
159 | 159 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | protected function getKeyListId() |
188 | 188 | { |
189 | 189 | $id='keyList'; |
190 | - if ($this->_cacheModel instanceof TSqlMapCacheModel) |
|
190 | + if($this->_cacheModel instanceof TSqlMapCacheModel) |
|
191 | 191 | $id.='_'.$this->_cacheModel->getId(); |
192 | 192 | return $id; |
193 | 193 | } |
@@ -197,7 +197,7 @@ 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 | 202 | $keyList=new TList(); |
203 | 203 | $this->getCache()->set($this->getKeyListId(), $keyList); |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | { |
229 | 229 | $keyList=$this->getKeyList(); |
230 | 230 | $cache=$this->getCache(); |
231 | - foreach ($keyList as $key) |
|
231 | + foreach($keyList as $key) |
|
232 | 232 | { |
233 | 233 | $cache->delete($key); |
234 | 234 | } |
@@ -241,18 +241,18 @@ discard block |
||
241 | 241 | */ |
242 | 242 | public function get($key) |
243 | 243 | { |
244 | - $result = $this->getCache()->get($key); |
|
245 | - if ($result === false) |
|
244 | + $result=$this->getCache()->get($key); |
|
245 | + if($result===false) |
|
246 | 246 | { |
247 | 247 | // if the key has not been found in cache (e.g expired), remove from keylist |
248 | 248 | $keyList=$this->getKeyList(); |
249 | - if ($keyList->contains($key)) |
|
249 | + if($keyList->contains($key)) |
|
250 | 250 | { |
251 | 251 | $keyList->remove($key); |
252 | 252 | $this->setKeyList($keyList); |
253 | 253 | } |
254 | 254 | } |
255 | - return $result === false ? null : $result; |
|
255 | + return $result===false ? null : $result; |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -260,11 +260,11 @@ 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); |
|
265 | + $this->getCache()->set($key, $value, $expire, $dependency); |
|
266 | 266 | $keyList=$this->getKeyList(); |
267 | - if (!$keyList->contains($key)) |
|
267 | + if(!$keyList->contains($key)) |
|
268 | 268 | { |
269 | 269 | $keyList->add($key); |
270 | 270 | $this->setKeyList($keyList); |
@@ -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 | } |
@@ -41,11 +41,11 @@ discard block |
||
41 | 41 | * @param mixed delegate for each data row retrieved. |
42 | 42 | * @param int number of page to fetch on initialization |
43 | 43 | */ |
44 | - public function __construct(IMappedStatement $statement,$parameter, $pageSize, $delegate=null, $page=0) |
|
44 | + public function __construct(IMappedStatement $statement, $parameter, $pageSize, $delegate=null, $page=0) |
|
45 | 45 | { |
46 | 46 | parent::__construct(); |
47 | 47 | parent::setCustomPaging(true); |
48 | - $this->initialize($statement,$parameter, $pageSize, $page); |
|
48 | + $this->initialize($statement, $parameter, $pageSize, $page); |
|
49 | 49 | $this->_delegate=$delegate; |
50 | 50 | } |
51 | 51 | |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | */ |
59 | 59 | protected function initialize($statement, $parameter, $pageSize, $page) |
60 | 60 | { |
61 | - $this->_statement = $statement; |
|
62 | - $this->_parameter = $parameter; |
|
61 | + $this->_statement=$statement; |
|
62 | + $this->_parameter=$parameter; |
|
63 | 63 | $this->setPageSize($pageSize); |
64 | 64 | $this->attachEventHandler('OnFetchData', array($this, 'fetchDataFromStatement')); |
65 | 65 | $this->gotoPage($page); |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | */ |
81 | 81 | protected function fetchDataFromStatement($sender, $param) |
82 | 82 | { |
83 | - $limit = $this->getOffsetAndLimit($param); |
|
84 | - $connection = $this->_statement->getManager()->getDbConnection(); |
|
85 | - $data = $this->_statement->executeQueryForList($connection, |
|
83 | + $limit=$this->getOffsetAndLimit($param); |
|
84 | + $connection=$this->_statement->getManager()->getDbConnection(); |
|
85 | + $data=$this->_statement->executeQueryForList($connection, |
|
86 | 86 | $this->_parameter, null, $limit[0], $limit[1], $this->_delegate); |
87 | 87 | $this->populateData($param, $data); |
88 | 88 | } |
@@ -112,49 +112,49 @@ discard block |
||
112 | 112 | */ |
113 | 113 | protected function populateData($param, $data) |
114 | 114 | { |
115 | - $total = $data instanceof TList ? $data->getCount() : count($data); |
|
116 | - $pageSize = $this->getPageSize(); |
|
115 | + $total=$data instanceof TList ? $data->getCount() : count($data); |
|
116 | + $pageSize=$this->getPageSize(); |
|
117 | 117 | if($total < 1) |
118 | 118 | { |
119 | 119 | $param->setData($data); |
120 | - $this->_prevPageList = null; |
|
121 | - $this->_nextPageList = null; |
|
120 | + $this->_prevPageList=null; |
|
121 | + $this->_nextPageList=null; |
|
122 | 122 | return; |
123 | 123 | } |
124 | 124 | |
125 | 125 | if($param->getNewPageIndex() < 1) |
126 | 126 | { |
127 | - $this->_prevPageList = null; |
|
127 | + $this->_prevPageList=null; |
|
128 | 128 | if($total <= $pageSize) |
129 | 129 | { |
130 | 130 | $param->setData($data); |
131 | - $this->_nextPageList = null; |
|
131 | + $this->_nextPageList=null; |
|
132 | 132 | } |
133 | 133 | else |
134 | 134 | { |
135 | 135 | $param->setData(array_slice($data, 0, $pageSize)); |
136 | - $this->_nextPageList = array_slice($data, $pageSize-1,$total); |
|
136 | + $this->_nextPageList=array_slice($data, $pageSize - 1, $total); |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | else |
140 | 140 | { |
141 | 141 | if($total <= $pageSize) |
142 | 142 | { |
143 | - $this->_prevPageList = array_slice($data, 0, $total); |
|
143 | + $this->_prevPageList=array_slice($data, 0, $total); |
|
144 | 144 | $param->setData(array()); |
145 | - $this->_nextPageList = null; |
|
145 | + $this->_nextPageList=null; |
|
146 | 146 | } |
147 | - else if($total <= $pageSize*2) |
|
147 | + else if($total <= $pageSize * 2) |
|
148 | 148 | { |
149 | - $this->_prevPageList = array_slice($data, 0, $pageSize); |
|
149 | + $this->_prevPageList=array_slice($data, 0, $pageSize); |
|
150 | 150 | $param->setData(array_slice($data, $pageSize, $total)); |
151 | - $this->_nextPageList = null; |
|
151 | + $this->_nextPageList=null; |
|
152 | 152 | } |
153 | 153 | else |
154 | 154 | { |
155 | - $this->_prevPageList = array_slice($data, 0, $pageSize); |
|
155 | + $this->_prevPageList=array_slice($data, 0, $pageSize); |
|
156 | 156 | $param->setData(array_slice($data, $pageSize, $pageSize)); |
157 | - $this->_nextPageList = array_slice($data, $pageSize*2, $total-$pageSize*2); |
|
157 | + $this->_nextPageList=array_slice($data, $pageSize * 2, $total - $pageSize * 2); |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | } |
@@ -166,9 +166,9 @@ discard block |
||
166 | 166 | */ |
167 | 167 | protected function getOffsetAndLimit($param) |
168 | 168 | { |
169 | - $index = $param->getNewPageIndex(); |
|
170 | - $pageSize = $this->getPageSize(); |
|
171 | - return $index < 1 ? array($index, $pageSize*2) : array(($index-1)*$pageSize, $pageSize*3); |
|
169 | + $index=$param->getNewPageIndex(); |
|
170 | + $pageSize=$this->getPageSize(); |
|
171 | + return $index < 1 ? array($index, $pageSize * 2) : array(($index - 1) * $pageSize, $pageSize * 3); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function registerTypeHandler(TSqlMapTypeHandler $handler) |
49 | 49 | { |
50 | - $this->_typeHandlers[$handler->getType()] = $handler; |
|
50 | + $this->_typeHandlers[$handler->getType()]=$handler; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -90,13 +90,13 @@ discard block |
||
90 | 90 | switch(strtolower($type)) |
91 | 91 | { |
92 | 92 | case 'integer': case 'int': |
93 | - $type = 'integer'; break; |
|
93 | + $type='integer'; break; |
|
94 | 94 | case 'float': case 'double': case 'decimal': |
95 | - $type = 'float'; break; |
|
95 | + $type='float'; break; |
|
96 | 96 | case 'boolean': case 'bool': |
97 | - $type = 'boolean'; break; |
|
97 | + $type='boolean'; break; |
|
98 | 98 | case 'string' : |
99 | - $type = 'string'; break; |
|
99 | + $type='string'; break; |
|
100 | 100 | default: |
101 | 101 | return $value; |
102 | 102 | } |
@@ -48,34 +48,34 @@ discard block |
||
48 | 48 | * @return mixed property value. |
49 | 49 | * @throws TInvalidDataValueException if property path is invalid. |
50 | 50 | */ |
51 | - public static function get($object,$path) |
|
51 | + public static function get($object, $path) |
|
52 | 52 | { |
53 | 53 | if(!is_array($object) && !is_object($object)) |
54 | 54 | return $object; |
55 | - $properties = explode('.', $path); |
|
55 | + $properties=explode('.', $path); |
|
56 | 56 | foreach($properties as $prop) |
57 | 57 | { |
58 | 58 | if(is_array($object) || $object instanceof ArrayAccess) |
59 | 59 | { |
60 | 60 | if(array_key_exists($prop, $object)) |
61 | - $object = $object[$prop]; |
|
61 | + $object=$object[$prop]; |
|
62 | 62 | else |
63 | - throw new TInvalidPropertyException('sqlmap_invalid_property',$path); |
|
63 | + throw new TInvalidPropertyException('sqlmap_invalid_property', $path); |
|
64 | 64 | } |
65 | 65 | else if(is_object($object)) |
66 | 66 | { |
67 | - $getter = 'get'.$prop; |
|
67 | + $getter='get'.$prop; |
|
68 | 68 | if(method_exists($object, $getter) && is_callable(array($object, $getter))) |
69 | - $object = $object->{$getter}(); |
|
69 | + $object=$object->{$getter}(); |
|
70 | 70 | else if(in_array($prop, array_keys(get_object_vars($object)))) |
71 | - $object = $object->{$prop}; |
|
71 | + $object=$object->{$prop}; |
|
72 | 72 | elseif(method_exists($object, '__get') && is_callable(array($object, '__get'))) |
73 | - $object = $object->{$prop}; |
|
73 | + $object=$object->{$prop}; |
|
74 | 74 | else |
75 | - throw new TInvalidPropertyException('sqlmap_invalid_property',$path); |
|
75 | + throw new TInvalidPropertyException('sqlmap_invalid_property', $path); |
|
76 | 76 | } |
77 | 77 | else |
78 | - throw new TInvalidPropertyException('sqlmap_invalid_property',$path); |
|
78 | + throw new TInvalidPropertyException('sqlmap_invalid_property', $path); |
|
79 | 79 | } |
80 | 80 | return $object; |
81 | 81 | } |
@@ -89,25 +89,25 @@ discard block |
||
89 | 89 | { |
90 | 90 | if(!is_array($object) && !is_object($object)) |
91 | 91 | return false; |
92 | - $properties = explode('.', $path); |
|
92 | + $properties=explode('.', $path); |
|
93 | 93 | foreach($properties as $prop) |
94 | 94 | { |
95 | 95 | if(is_array($object) || $object instanceof ArrayAccess) |
96 | 96 | { |
97 | 97 | if(array_key_exists($prop, $object)) |
98 | - $object = $object[$prop]; |
|
98 | + $object=$object[$prop]; |
|
99 | 99 | else |
100 | 100 | return false; |
101 | 101 | } |
102 | 102 | else if(is_object($object)) |
103 | 103 | { |
104 | - $getter = 'get'.$prop; |
|
104 | + $getter='get'.$prop; |
|
105 | 105 | if(method_exists($object, $getter) && is_callable(array($object, $getter))) |
106 | - $object = $object->{$getter}(); |
|
106 | + $object=$object->{$getter}(); |
|
107 | 107 | else if(in_array($prop, array_keys(get_object_vars($object)))) |
108 | - $object = $object->{$prop}; |
|
108 | + $object=$object->{$prop}; |
|
109 | 109 | elseif(method_exists($object, '__get') && is_callable(array($object, '__get'))) |
110 | - $object = $object->{$prop}; |
|
110 | + $object=$object->{$prop}; |
|
111 | 111 | else |
112 | 112 | return false; |
113 | 113 | } |
@@ -126,27 +126,27 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public static function set(&$originalObject, $path, $value) |
128 | 128 | { |
129 | - $properties = explode('.', $path); |
|
130 | - $prop = array_pop($properties); |
|
129 | + $properties=explode('.', $path); |
|
130 | + $prop=array_pop($properties); |
|
131 | 131 | if(count($properties) > 0) |
132 | - $object = self::get($originalObject, implode('.',$properties)); |
|
132 | + $object=self::get($originalObject, implode('.', $properties)); |
|
133 | 133 | else |
134 | - $object = &$originalObject; |
|
134 | + $object=&$originalObject; |
|
135 | 135 | |
136 | 136 | if(is_array($object) || $object instanceof ArrayAccess) |
137 | 137 | { |
138 | - $object[$prop] = $value; |
|
138 | + $object[$prop]=$value; |
|
139 | 139 | } |
140 | 140 | else if(is_object($object)) |
141 | 141 | { |
142 | - $setter = 'set'.$prop; |
|
143 | - if (method_exists($object, $setter) && is_callable(array($object, $setter))) |
|
142 | + $setter='set'.$prop; |
|
143 | + if(method_exists($object, $setter) && is_callable(array($object, $setter))) |
|
144 | 144 | $object->{$setter}($value); |
145 | 145 | else |
146 | - $object->{$prop} = $value; |
|
146 | + $object->{$prop}=$value; |
|
147 | 147 | } |
148 | 148 | else |
149 | - throw new TInvalidPropertyException('sqlmap_invalid_property_type',$path); |
|
149 | + throw new TInvalidPropertyException('sqlmap_invalid_property_type', $path); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | } |
@@ -22,14 +22,14 @@ discard block |
||
22 | 22 | array_shift($args); |
23 | 23 | $n=count($args); |
24 | 24 | $tokens=array(); |
25 | - for($i=0;$i<$n;++$i) |
|
25 | + for($i=0; $i < $n; ++$i) |
|
26 | 26 | { |
27 | 27 | if($args[$i] instanceof SimpleXmlElement) |
28 | 28 | $tokens['{'.$i.'}']=$this->implodeNode($args[$i]); |
29 | 29 | else |
30 | 30 | $tokens['{'.$i.'}']=TPropertyValue::ensureString($args[$i]); |
31 | 31 | } |
32 | - parent::__construct(strtr($errorMessage,$tokens)); |
|
32 | + parent::__construct(strtr($errorMessage, $tokens)); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | { |
41 | 41 | $attributes=array(); |
42 | 42 | foreach($node->attributes() as $k=>$v) |
43 | - $attributes[]=$k.'="'.(string)$v.'"'; |
|
44 | - return '<'.$node->getName().' '.implode(' ',$attributes).'>'; |
|
43 | + $attributes[]=$k.'="'.(string) $v.'"'; |
|
44 | + return '<'.$node->getName().' '.implode(' ', $attributes).'>'; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | public function __construct($cacheModel=null) |
28 | 28 | { |
29 | - $this->_cacheModel = $cacheModel; |
|
29 | + $this->_cacheModel=$cacheModel; |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | protected function getBaseKeyKeyName() |
@@ -36,13 +36,13 @@ discard block |
||
36 | 36 | |
37 | 37 | protected function getBaseKey() |
38 | 38 | { |
39 | - $cache = $this->getCache(); |
|
40 | - $keyname = $this->getBaseKeyKeyName(); |
|
41 | - $basekey = $cache->get($keyname); |
|
42 | - if (!$basekey) |
|
39 | + $cache=$this->getCache(); |
|
40 | + $keyname=$this->getBaseKeyKeyName(); |
|
41 | + $basekey=$cache->get($keyname); |
|
42 | + if(!$basekey) |
|
43 | 43 | { |
44 | - $basekey = DxUtil::generateRandomHash(8); |
|
45 | - $cache->set($keyname,$basekey); |
|
44 | + $basekey=DxUtil::generateRandomHash(8); |
|
45 | + $cache->set($keyname, $basekey); |
|
46 | 46 | } |
47 | 47 | return $basekey; |
48 | 48 | } |
@@ -64,23 +64,23 @@ discard block |
||
64 | 64 | |
65 | 65 | public function get($key) |
66 | 66 | { |
67 | - $result = $this->getCache()->get($this->getCacheKey($key)); |
|
68 | - return $result === false ? null : $result; |
|
67 | + $result=$this->getCache()->get($this->getCacheKey($key)); |
|
68 | + return $result===false ? null : $result; |
|
69 | 69 | } |
70 | 70 | |
71 | - public function set($key, $value,$expire=0,$dependency=null) |
|
71 | + public function set($key, $value, $expire=0, $dependency=null) |
|
72 | 72 | { |
73 | - $this->getCache()->set($this->getCacheKey($key), $value, $expire,$dependency); |
|
73 | + $this->getCache()->set($this->getCacheKey($key), $value, $expire, $dependency); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | protected function getCache() |
77 | 77 | { |
78 | - if (!$this->_cache) |
|
79 | - $this->_cache = Prado::getApplication()->getCache(); |
|
78 | + if(!$this->_cache) |
|
79 | + $this->_cache=Prado::getApplication()->getCache(); |
|
80 | 80 | return $this->_cache; |
81 | 81 | } |
82 | 82 | |
83 | - public function add($id,$value,$expire=0,$dependency=null) |
|
83 | + public function add($id, $value, $expire=0, $dependency=null) |
|
84 | 84 | { |
85 | 85 | throw new TSqlMapException('sqlmap_use_set_to_store_cache'); |
86 | 86 | } |