@@ -236,6 +236,7 @@ discard block |
||
236 | 236 | * Return record data from sql query. |
237 | 237 | * @param TActiveRecord active record finder instance. |
238 | 238 | * @param TActiveRecordCriteria sql query |
239 | + * @param TSqlCriteria $criteria |
|
239 | 240 | * @return array result. |
240 | 241 | */ |
241 | 242 | public function findRecordBySql(TActiveRecord $record, $criteria) |
@@ -247,6 +248,7 @@ discard block |
||
247 | 248 | * Return record data from sql query. |
248 | 249 | * @param TActiveRecord active record finder instance. |
249 | 250 | * @param TActiveRecordCriteria sql query |
251 | + * @param TSqlCriteria $criteria |
|
250 | 252 | * @return TDbDataReader result iterator. |
251 | 253 | */ |
252 | 254 | public function findRecordsBySql(TActiveRecord $record, $criteria) |
@@ -288,6 +290,7 @@ discard block |
||
288 | 290 | /** |
289 | 291 | * Sets the last insert ID to the corresponding property of the record if available. |
290 | 292 | * @param TActiveRecord record for insertion |
293 | + * @param TActiveRecord $record |
|
291 | 294 | */ |
292 | 295 | protected function updatePostInsert($record) |
293 | 296 | { |
@@ -405,6 +408,7 @@ discard block |
||
405 | 408 | * Delete multiple records by criteria. |
406 | 409 | * @param TActiveRecord active record finder instance. |
407 | 410 | * @param TActiveRecordCriteria search criteria |
411 | + * @param TSqlCriteria $criteria |
|
408 | 412 | * @return int number of records. |
409 | 413 | */ |
410 | 414 | public function deleteRecordsByCriteria(TActiveRecord $record, $criteria) |
@@ -79,16 +79,14 @@ |
||
79 | 79 | throw new TActiveRecordException('ar_invalid_tablename_property', |
80 | 80 | get_class($record), self::TABLE_CONST); |
81 | 81 | return $value; |
82 | - } |
|
83 | - elseif ($class->hasMethod(self::TABLE_METHOD)) |
|
82 | + } elseif ($class->hasMethod(self::TABLE_METHOD)) |
|
84 | 83 | { |
85 | 84 | $value = $record->{self::TABLE_METHOD}(); |
86 | 85 | if(empty($value)) |
87 | 86 | throw new TActiveRecordException('ar_invalid_tablename_method', |
88 | 87 | get_class($record), self::TABLE_METHOD); |
89 | 88 | return $value; |
90 | - } |
|
91 | - else |
|
89 | + } else |
|
92 | 90 | return strtolower(get_class($record)); |
93 | 91 | } |
94 | 92 |
@@ -32,19 +32,19 @@ discard block |
||
32 | 32 | class TActiveRecordGateway extends \Prado\TComponent |
33 | 33 | { |
34 | 34 | private $_manager; |
35 | - private $_tables = []; //table cache |
|
36 | - private $_meta = []; //meta data cache. |
|
37 | - private $_commandBuilders = []; |
|
35 | + private $_tables=[]; //table cache |
|
36 | + private $_meta=[]; //meta data cache. |
|
37 | + private $_commandBuilders=[]; |
|
38 | 38 | private $_currentRecord; |
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Constant name for specifying optional table name in TActiveRecord. |
42 | 42 | */ |
43 | - const TABLE_CONST = 'TABLE'; |
|
43 | + const TABLE_CONST='TABLE'; |
|
44 | 44 | /** |
45 | 45 | * Method name for returning optional table name in in TActiveRecord |
46 | 46 | */ |
47 | - const TABLE_METHOD = 'table'; |
|
47 | + const TABLE_METHOD='table'; |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * Record gateway constructor. |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function __construct(TActiveRecordManager $manager) |
54 | 54 | { |
55 | - $this->_manager = $manager; |
|
55 | + $this->_manager=$manager; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -71,18 +71,18 @@ discard block |
||
71 | 71 | */ |
72 | 72 | protected function getRecordTableName(TActiveRecord $record) |
73 | 73 | { |
74 | - $class = new ReflectionClass($record); |
|
74 | + $class=new ReflectionClass($record); |
|
75 | 75 | if($class->hasConstant(self::TABLE_CONST)) |
76 | 76 | { |
77 | - $value = $class->getConstant(self::TABLE_CONST); |
|
77 | + $value=$class->getConstant(self::TABLE_CONST); |
|
78 | 78 | if(empty($value)) |
79 | 79 | throw new TActiveRecordException('ar_invalid_tablename_property', |
80 | 80 | get_class($record), self::TABLE_CONST); |
81 | 81 | return $value; |
82 | 82 | } |
83 | - elseif ($class->hasMethod(self::TABLE_METHOD)) |
|
83 | + elseif($class->hasMethod(self::TABLE_METHOD)) |
|
84 | 84 | { |
85 | - $value = $record->{self::TABLE_METHOD}(); |
|
85 | + $value=$record->{self::TABLE_METHOD}(); |
|
86 | 86 | if(empty($value)) |
87 | 87 | throw new TActiveRecordException('ar_invalid_tablename_method', |
88 | 88 | get_class($record), self::TABLE_METHOD); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function getRecordTableInfo(TActiveRecord $record) |
101 | 101 | { |
102 | - $tableName = $this->getRecordTableName($record); |
|
102 | + $tableName=$this->getRecordTableName($record); |
|
103 | 103 | return $this->getTableInfo($record->getDbConnection(), $tableName); |
104 | 104 | } |
105 | 105 | |
@@ -111,27 +111,27 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function getTableInfo(TDbConnection $connection, $tableName) |
113 | 113 | { |
114 | - $connStr = $connection->getConnectionString(); |
|
115 | - $key = $connStr . $tableName; |
|
114 | + $connStr=$connection->getConnectionString(); |
|
115 | + $key=$connStr.$tableName; |
|
116 | 116 | if(!isset($this->_tables[$key])) |
117 | 117 | { |
118 | 118 | //call this first to ensure that unserializing the cache |
119 | 119 | //will find the correct driver dependent classes. |
120 | 120 | if(!isset($this->_meta[$connStr])) |
121 | 121 | { |
122 | - $this->_meta[$connStr] = TDbMetaData::getInstance($connection); |
|
122 | + $this->_meta[$connStr]=TDbMetaData::getInstance($connection); |
|
123 | 123 | } |
124 | 124 | |
125 | - $tableInfo = null; |
|
126 | - if(($cache = $this->getManager()->getCache()) !== null) |
|
127 | - $tableInfo = $cache->get($key); |
|
125 | + $tableInfo=null; |
|
126 | + if(($cache=$this->getManager()->getCache())!==null) |
|
127 | + $tableInfo=$cache->get($key); |
|
128 | 128 | if(empty($tableInfo)) |
129 | 129 | { |
130 | - $tableInfo = $this->_meta[$connStr]->getTableInfo($tableName); |
|
131 | - if($cache !== null) |
|
130 | + $tableInfo=$this->_meta[$connStr]->getTableInfo($tableName); |
|
131 | + if($cache!==null) |
|
132 | 132 | $cache->set($key, $tableInfo); |
133 | 133 | } |
134 | - $this->_tables[$key] = $tableInfo; |
|
134 | + $this->_tables[$key]=$tableInfo; |
|
135 | 135 | } |
136 | 136 | return $this->_tables[$key]; |
137 | 137 | } |
@@ -142,20 +142,20 @@ discard block |
||
142 | 142 | */ |
143 | 143 | public function getCommand(TActiveRecord $record) |
144 | 144 | { |
145 | - $conn = $record->getDbConnection(); |
|
146 | - $connStr = $conn->getConnectionString(); |
|
147 | - $tableInfo = $this->getRecordTableInfo($record); |
|
145 | + $conn=$record->getDbConnection(); |
|
146 | + $connStr=$conn->getConnectionString(); |
|
147 | + $tableInfo=$this->getRecordTableInfo($record); |
|
148 | 148 | if(!isset($this->_commandBuilders[$connStr])) |
149 | 149 | { |
150 | - $builder = $tableInfo->createCommandBuilder($record->getDbConnection()); |
|
151 | - $command = new TDataGatewayCommand($builder); |
|
152 | - $command->OnCreateCommand[] = [$this, 'onCreateCommand']; |
|
153 | - $command->OnExecuteCommand[] = [$this, 'onExecuteCommand']; |
|
154 | - $this->_commandBuilders[$connStr] = $command; |
|
150 | + $builder=$tableInfo->createCommandBuilder($record->getDbConnection()); |
|
151 | + $command=new TDataGatewayCommand($builder); |
|
152 | + $command->OnCreateCommand[]=[$this, 'onCreateCommand']; |
|
153 | + $command->OnExecuteCommand[]=[$this, 'onExecuteCommand']; |
|
154 | + $this->_commandBuilders[$connStr]=$command; |
|
155 | 155 | |
156 | 156 | } |
157 | 157 | $this->_commandBuilders[$connStr]->getBuilder()->setTableInfo($tableInfo); |
158 | - $this->_currentRecord = $record; |
|
158 | + $this->_currentRecord=$record; |
|
159 | 159 | return $this->_commandBuilders[$connStr]; |
160 | 160 | } |
161 | 161 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | public function onCreateCommand($sender, $param) |
173 | 173 | { |
174 | 174 | $this->raiseEvent('OnCreateCommand', $this, $param); |
175 | - if($this->_currentRecord !== null) |
|
175 | + if($this->_currentRecord!==null) |
|
176 | 176 | $this->_currentRecord->onCreateCommand($param); |
177 | 177 | } |
178 | 178 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | public function onExecuteCommand($sender, $param) |
191 | 191 | { |
192 | 192 | $this->raiseEvent('OnExecuteCommand', $this, $param); |
193 | - if($this->_currentRecord !== null) |
|
193 | + if($this->_currentRecord!==null) |
|
194 | 194 | $this->_currentRecord->onExecuteCommand($param); |
195 | 195 | } |
196 | 196 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | */ |
204 | 204 | public function findRecordByPK(TActiveRecord $record, $keys) |
205 | 205 | { |
206 | - $command = $this->getCommand($record); |
|
206 | + $command=$this->getCommand($record); |
|
207 | 207 | return $command->findByPk($keys); |
208 | 208 | } |
209 | 209 | |
@@ -227,9 +227,9 @@ discard block |
||
227 | 227 | * @param boolean true to return multiple rows as iterator, false returns first row. |
228 | 228 | * @return mixed matching data. |
229 | 229 | */ |
230 | - public function findRecordsByCriteria(TActiveRecord $record, $criteria, $iterator = false) |
|
230 | + public function findRecordsByCriteria(TActiveRecord $record, $criteria, $iterator=false) |
|
231 | 231 | { |
232 | - $command = $this->getCommand($record); |
|
232 | + $command=$this->getCommand($record); |
|
233 | 233 | return $iterator ? $command->findAll($criteria) : $command->find($criteria); |
234 | 234 | } |
235 | 235 | |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | public function insert(TActiveRecord $record) |
280 | 280 | { |
281 | 281 | //$this->updateAssociatedRecords($record,true); |
282 | - $result = $this->getCommand($record)->insert($this->getInsertValues($record)); |
|
282 | + $result=$this->getCommand($record)->insert($this->getInsertValues($record)); |
|
283 | 283 | if($result) |
284 | 284 | $this->updatePostInsert($record); |
285 | 285 | //$this->updateAssociatedRecords($record); |
@@ -292,8 +292,8 @@ discard block |
||
292 | 292 | */ |
293 | 293 | protected function updatePostInsert($record) |
294 | 294 | { |
295 | - $command = $this->getCommand($record); |
|
296 | - $tableInfo = $command->getTableInfo(); |
|
295 | + $command=$this->getCommand($record); |
|
296 | + $tableInfo=$command->getTableInfo(); |
|
297 | 297 | foreach($tableInfo->getColumns() as $name => $column) |
298 | 298 | { |
299 | 299 | if($column->hasSequence()) |
@@ -307,21 +307,21 @@ discard block |
||
307 | 307 | */ |
308 | 308 | protected function getInsertValues(TActiveRecord $record) |
309 | 309 | { |
310 | - $values = []; |
|
311 | - $tableInfo = $this->getCommand($record)->getTableInfo(); |
|
310 | + $values=[]; |
|
311 | + $tableInfo=$this->getCommand($record)->getTableInfo(); |
|
312 | 312 | foreach($tableInfo->getColumns() as $name => $column) |
313 | 313 | { |
314 | 314 | if($column->getIsExcluded()) |
315 | 315 | continue; |
316 | - $value = $record->getColumnValue($name); |
|
317 | - if(!$column->getAllowNull() && $value === null && !$column->hasSequence() && ($column->getDefaultValue() === TDbTableColumn::UNDEFINED_VALUE)) |
|
316 | + $value=$record->getColumnValue($name); |
|
317 | + if(!$column->getAllowNull() && $value===null && !$column->hasSequence() && ($column->getDefaultValue()===TDbTableColumn::UNDEFINED_VALUE)) |
|
318 | 318 | { |
319 | 319 | throw new TActiveRecordException( |
320 | 320 | 'ar_value_must_not_be_null', get_class($record), |
321 | 321 | $tableInfo->getTableFullName(), $name); |
322 | 322 | } |
323 | - if($value !== null) |
|
324 | - $values[$name] = $value; |
|
323 | + if($value!==null) |
|
324 | + $values[$name]=$value; |
|
325 | 325 | } |
326 | 326 | return $values; |
327 | 327 | } |
@@ -334,39 +334,39 @@ discard block |
||
334 | 334 | public function update(TActiveRecord $record) |
335 | 335 | { |
336 | 336 | //$this->updateAssociatedRecords($record,true); |
337 | - list($data, $keys) = $this->getUpdateValues($record); |
|
338 | - $result = $this->getCommand($record)->updateByPk($data, $keys); |
|
337 | + list($data, $keys)=$this->getUpdateValues($record); |
|
338 | + $result=$this->getCommand($record)->updateByPk($data, $keys); |
|
339 | 339 | //$this->updateAssociatedRecords($record); |
340 | 340 | return $result; |
341 | 341 | } |
342 | 342 | |
343 | 343 | protected function getUpdateValues(TActiveRecord $record) |
344 | 344 | { |
345 | - $values = []; |
|
346 | - $tableInfo = $this->getCommand($record)->getTableInfo(); |
|
347 | - $primary = []; |
|
345 | + $values=[]; |
|
346 | + $tableInfo=$this->getCommand($record)->getTableInfo(); |
|
347 | + $primary=[]; |
|
348 | 348 | foreach($tableInfo->getColumns() as $name => $column) |
349 | 349 | { |
350 | 350 | if($column->getIsExcluded()) |
351 | 351 | continue; |
352 | - $value = $record->getColumnValue($name); |
|
353 | - if(!$column->getAllowNull() && $value === null && ($column->getDefaultValue() === TDbTableColumn::UNDEFINED_VALUE)) |
|
352 | + $value=$record->getColumnValue($name); |
|
353 | + if(!$column->getAllowNull() && $value===null && ($column->getDefaultValue()===TDbTableColumn::UNDEFINED_VALUE)) |
|
354 | 354 | { |
355 | 355 | throw new TActiveRecordException( |
356 | 356 | 'ar_value_must_not_be_null', get_class($record), |
357 | 357 | $tableInfo->getTableFullName(), $name); |
358 | 358 | } |
359 | 359 | if($column->getIsPrimaryKey()) |
360 | - $primary[$name] = $value; |
|
360 | + $primary[$name]=$value; |
|
361 | 361 | else |
362 | - $values[$name] = $value; |
|
362 | + $values[$name]=$value; |
|
363 | 363 | } |
364 | - return [$values,$primary]; |
|
364 | + return [$values, $primary]; |
|
365 | 365 | } |
366 | 366 | |
367 | - protected function updateAssociatedRecords(TActiveRecord $record, $updateBelongsTo = false) |
|
367 | + protected function updateAssociatedRecords(TActiveRecord $record, $updateBelongsTo=false) |
|
368 | 368 | { |
369 | - $context = new TActiveRecordRelationContext($record); |
|
369 | + $context=new TActiveRecordRelationContext($record); |
|
370 | 370 | return $context->updateAssociatedRecords($updateBelongsTo); |
371 | 371 | } |
372 | 372 | |
@@ -382,12 +382,12 @@ discard block |
||
382 | 382 | |
383 | 383 | protected function getPrimaryKeyValues(TActiveRecord $record) |
384 | 384 | { |
385 | - $tableInfo = $this->getCommand($record)->getTableInfo(); |
|
386 | - $primary = []; |
|
385 | + $tableInfo=$this->getCommand($record)->getTableInfo(); |
|
386 | + $primary=[]; |
|
387 | 387 | foreach($tableInfo->getColumns() as $name => $column) |
388 | 388 | { |
389 | 389 | if($column->getIsPrimaryKey()) |
390 | - $primary[$name] = $record->getColumnValue($name); |
|
390 | + $primary[$name]=$record->getColumnValue($name); |
|
391 | 391 | } |
392 | 392 | return $primary; |
393 | 393 | } |
@@ -423,9 +423,9 @@ discard block |
||
423 | 423 | protected function raiseCommandEvent($event, $command, $record, $criteria) |
424 | 424 | { |
425 | 425 | if(!($criteria instanceof TSqlCriteria)) |
426 | - $criteria = new TActiveRecordCriteria(null, $criteria); |
|
427 | - $param = new TActiveRecordEventParameter($command, $record, $criteria); |
|
428 | - $manager = $record->getRecordManager(); |
|
426 | + $criteria=new TActiveRecordCriteria(null, $criteria); |
|
427 | + $param=new TActiveRecordEventParameter($command, $record, $criteria); |
|
428 | + $manager=$record->getRecordManager(); |
|
429 | 429 | $manager->{$event}($param); |
430 | 430 | $record->{$event}($param); |
431 | 431 | } |
@@ -54,7 +54,7 @@ |
||
54 | 54 | |
55 | 55 | /** |
56 | 56 | * @param TDbConnection database connection. |
57 | - * @return TDbCommandBuilder new command builder |
|
57 | + * @return TMssqlCommandBuilder new command builder |
|
58 | 58 | */ |
59 | 59 | public function createCommandBuilder($connection) |
60 | 60 | { |
@@ -49,7 +49,7 @@ |
||
49 | 49 | public function getTableFullName() |
50 | 50 | { |
51 | 51 | //MSSQL alway returns the catalog, schem and table names. |
52 | - return '[' . $this->getCatalogName() . '].[' . $this->getSchemaName() . '].[' . $this->getTableName() . ']'; |
|
52 | + return '['.$this->getCatalogName().'].['.$this->getSchemaName().'].['.$this->getTableName().']'; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -48,7 +48,7 @@ |
||
48 | 48 | |
49 | 49 | /** |
50 | 50 | * @param TDbConnection database connection. |
51 | - * @return TDbCommandBuilder new command builder |
|
51 | + * @return TMysqlCommandBuilder new command builder |
|
52 | 52 | */ |
53 | 53 | public function createCommandBuilder($connection) |
54 | 54 | { |
@@ -40,10 +40,10 @@ |
||
40 | 40 | */ |
41 | 41 | public function getTableFullName() |
42 | 42 | { |
43 | - if(($schema = $this->getSchemaName()) !== null) |
|
44 | - return '`' . $schema . '`.`' . $this->getTableName() . '`'; |
|
43 | + if(($schema=$this->getSchemaName())!==null) |
|
44 | + return '`'.$schema.'`.`'.$this->getTableName().'`'; |
|
45 | 45 | else |
46 | - return '`' . $this->getTableName() . '`'; |
|
46 | + return '`'.$this->getTableName().'`'; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -48,7 +48,7 @@ |
||
48 | 48 | |
49 | 49 | /** |
50 | 50 | * @param TDbConnection database connection. |
51 | - * @return TDbCommandBuilder new command builder |
|
51 | + * @return TPgsqlCommandBuilder new command builder |
|
52 | 52 | */ |
53 | 53 | public function createCommandBuilder($connection) |
54 | 54 | { |
@@ -40,8 +40,8 @@ |
||
40 | 40 | */ |
41 | 41 | public function getTableFullName() |
42 | 42 | { |
43 | - if(($schema = $this->getSchemaName()) !== null) |
|
44 | - return $schema . '.' . $this->getTableName(); |
|
43 | + if(($schema=$this->getSchemaName())!==null) |
|
44 | + return $schema.'.'.$this->getTableName(); |
|
45 | 45 | else |
46 | 46 | return $this->getTableName(); |
47 | 47 | } |
@@ -29,7 +29,7 @@ |
||
29 | 29 | { |
30 | 30 | /** |
31 | 31 | * @param TDbConnection database connection. |
32 | - * @return TDbCommandBuilder new command builder |
|
32 | + * @return TSqliteCommandBuilder new command builder |
|
33 | 33 | */ |
34 | 34 | public function createCommandBuilder($connection) |
35 | 35 | { |
@@ -41,7 +41,7 @@ |
||
41 | 41 | */ |
42 | 42 | public function getTableFullName() |
43 | 43 | { |
44 | - return "'" . $this->getTableName() . "'"; |
|
44 | + return "'".$this->getTableName()."'"; |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 |
@@ -191,7 +191,6 @@ discard block |
||
191 | 191 | * array('col1' => 'NULL', '*') |
192 | 192 | * // SELECT `col1`, `col2`, `col3`, NULL AS `col1` FROM... |
193 | 193 | * </code> |
194 | - * @param mixed $value |
|
195 | 194 | * @return array of generated fields - use implode(', ', $selectfieldlist) to collapse field list for usage |
196 | 195 | * @since 3.1.7 |
197 | 196 | * @todo add support for table aliasing |
@@ -399,7 +398,7 @@ discard block |
||
399 | 398 | /** |
400 | 399 | * Returns a list of insert field name and a list of binding names. |
401 | 400 | * @param object array or object to be inserted. |
402 | - * @return array tuple ($fields, $bindings) |
|
401 | + * @return string[] tuple ($fields, $bindings) |
|
403 | 402 | */ |
404 | 403 | protected function getInsertFieldBindings($values) |
405 | 404 | { |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param TDbConnection database connection. |
32 | 32 | * @param TDbTableInfo table information. |
33 | 33 | */ |
34 | - public function __construct($connection = null, $tableInfo = null) |
|
34 | + public function __construct($connection=null, $tableInfo=null) |
|
35 | 35 | { |
36 | 36 | $this->setDbConnection($connection); |
37 | 37 | $this->setTableInfo($tableInfo); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function setDbConnection($value) |
52 | 52 | { |
53 | - $this->_connection = $value; |
|
53 | + $this->_connection=$value; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function setTableInfo($value) |
60 | 60 | { |
61 | - $this->_tableInfo = $value; |
|
61 | + $this->_tableInfo=$value; |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -91,13 +91,13 @@ discard block |
||
91 | 91 | * @param integer row offset, -1 to ignore offset. |
92 | 92 | * @return string SQL with limit and offset. |
93 | 93 | */ |
94 | - public function applyLimitOffset($sql, $limit = -1, $offset = -1) |
|
94 | + public function applyLimitOffset($sql, $limit=-1, $offset=-1) |
|
95 | 95 | { |
96 | - $limit = $limit !== null ? (int)$limit : -1; |
|
97 | - $offset = $offset !== null ? (int)$offset : -1; |
|
98 | - $limitStr = $limit >= 0 ? ' LIMIT ' . $limit : ''; |
|
99 | - $offsetStr = $offset >= 0 ? ' OFFSET ' . $offset : ''; |
|
100 | - return $sql . $limitStr . $offsetStr; |
|
96 | + $limit=$limit!==null ? (int) $limit : -1; |
|
97 | + $offset=$offset!==null ? (int) $offset : -1; |
|
98 | + $limitStr=$limit >= 0 ? ' LIMIT '.$limit : ''; |
|
99 | + $offsetStr=$offset >= 0 ? ' OFFSET '.$offset : ''; |
|
100 | + return $sql.$limitStr.$offsetStr; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -107,21 +107,21 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function applyOrdering($sql, $ordering) |
109 | 109 | { |
110 | - $orders = []; |
|
110 | + $orders=[]; |
|
111 | 111 | foreach($ordering as $name => $direction) |
112 | 112 | { |
113 | - $direction = strtolower($direction) == 'desc' ? 'DESC' : 'ASC'; |
|
114 | - if(false !== strpos($name, '(') && false !== strpos($name, ')')) { |
|
113 | + $direction=strtolower($direction)=='desc' ? 'DESC' : 'ASC'; |
|
114 | + if(false!==strpos($name, '(') && false!==strpos($name, ')')) { |
|
115 | 115 | // key is a function (bad practice, but we need to handle it) |
116 | - $key = $name; |
|
116 | + $key=$name; |
|
117 | 117 | } else { |
118 | 118 | // key is a column |
119 | - $key = $this->getTableInfo()->getColumn($name)->getColumnName(); |
|
119 | + $key=$this->getTableInfo()->getColumn($name)->getColumnName(); |
|
120 | 120 | } |
121 | - $orders[] = $key . ' ' . $direction; |
|
121 | + $orders[]=$key.' '.$direction; |
|
122 | 122 | } |
123 | 123 | if(count($orders) > 0) |
124 | - $sql .= ' ORDER BY ' . implode(', ', $orders); |
|
124 | + $sql.=' ORDER BY '.implode(', ', $orders); |
|
125 | 125 | return $sql; |
126 | 126 | } |
127 | 127 | |
@@ -135,15 +135,15 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function getSearchExpression($fields, $keywords) |
137 | 137 | { |
138 | - if(strlen(trim($keywords)) == 0) return ''; |
|
139 | - $words = preg_split('/\s/u', $keywords); |
|
140 | - $conditions = []; |
|
138 | + if(strlen(trim($keywords))==0) return ''; |
|
139 | + $words=preg_split('/\s/u', $keywords); |
|
140 | + $conditions=[]; |
|
141 | 141 | foreach($fields as $field) |
142 | 142 | { |
143 | - $column = $this->getTableInfo()->getColumn($field)->getColumnName(); |
|
144 | - $conditions[] = $this->getSearchCondition($column, $words); |
|
143 | + $column=$this->getTableInfo()->getColumn($field)->getColumnName(); |
|
144 | + $conditions[]=$this->getSearchCondition($column, $words); |
|
145 | 145 | } |
146 | - return '(' . implode(' OR ', $conditions) . ')'; |
|
146 | + return '('.implode(' OR ', $conditions).')'; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -153,10 +153,10 @@ discard block |
||
153 | 153 | */ |
154 | 154 | protected function getSearchCondition($column, $words) |
155 | 155 | { |
156 | - $conditions = []; |
|
156 | + $conditions=[]; |
|
157 | 157 | foreach($words as $word) |
158 | - $conditions[] = $column . ' LIKE ' . $this->getDbConnection()->quoteString('%' . $word . '%'); |
|
159 | - return '(' . implode(' AND ', $conditions) . ')'; |
|
158 | + $conditions[]=$column.' LIKE '.$this->getDbConnection()->quoteString('%'.$word.'%'); |
|
159 | + return '('.implode(' AND ', $conditions).')'; |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -198,104 +198,104 @@ discard block |
||
198 | 198 | * @todo add support for table aliasing |
199 | 199 | * @todo add support for quoting of column aliasing |
200 | 200 | */ |
201 | - public function getSelectFieldList($data = '*') { |
|
201 | + public function getSelectFieldList($data='*') { |
|
202 | 202 | if(is_scalar($data)) { |
203 | - $tmp = explode(',', $data); |
|
204 | - $result = []; |
|
203 | + $tmp=explode(',', $data); |
|
204 | + $result=[]; |
|
205 | 205 | foreach($tmp as $v) |
206 | - $result[] = trim($v); |
|
206 | + $result[]=trim($v); |
|
207 | 207 | return $result; |
208 | 208 | } |
209 | 209 | |
210 | - $bHasWildcard = false; |
|
211 | - $result = []; |
|
210 | + $bHasWildcard=false; |
|
211 | + $result=[]; |
|
212 | 212 | if(is_array($data) || $data instanceof Traversable) { |
213 | - $columns = $this->getTableInfo()->getColumns(); |
|
213 | + $columns=$this->getTableInfo()->getColumns(); |
|
214 | 214 | foreach($data as $key => $value) { |
215 | - if($key === '*' || $value === '*') { |
|
216 | - $bHasWildcard = true; |
|
215 | + if($key==='*' || $value==='*') { |
|
216 | + $bHasWildcard=true; |
|
217 | 217 | continue; |
218 | 218 | } |
219 | 219 | |
220 | - if(strToUpper($key) === 'NULL') { |
|
221 | - $result[] = 'NULL'; |
|
220 | + if(strToUpper($key)==='NULL') { |
|
221 | + $result[]='NULL'; |
|
222 | 222 | continue; |
223 | 223 | } |
224 | 224 | |
225 | - if(strpos($key, '(') !== false && strpos($key, ')') !== false) { |
|
226 | - $result[] = $key; |
|
225 | + if(strpos($key, '(')!==false && strpos($key, ')')!==false) { |
|
226 | + $result[]=$key; |
|
227 | 227 | continue; |
228 | 228 | } |
229 | 229 | |
230 | - if(stripos($key, 'AS') !== false) { |
|
231 | - $result[] = $key; |
|
230 | + if(stripos($key, 'AS')!==false) { |
|
231 | + $result[]=$key; |
|
232 | 232 | continue; |
233 | 233 | } |
234 | 234 | |
235 | - if(stripos($value, 'AS') !== false) { |
|
236 | - $result[] = $value; |
|
235 | + if(stripos($value, 'AS')!==false) { |
|
236 | + $result[]=$value; |
|
237 | 237 | continue; |
238 | 238 | } |
239 | 239 | |
240 | - $v = isset($columns[$value]); |
|
241 | - $k = isset($columns[$key]); |
|
240 | + $v=isset($columns[$value]); |
|
241 | + $k=isset($columns[$key]); |
|
242 | 242 | if(is_int($key) && $v) { |
243 | - $key = $value; |
|
244 | - $k = $v; |
|
243 | + $key=$value; |
|
244 | + $k=$v; |
|
245 | 245 | } |
246 | 246 | |
247 | - if(strToUpper($value) === 'NULL') { |
|
247 | + if(strToUpper($value)==='NULL') { |
|
248 | 248 | if($k) |
249 | - $result[] = 'NULL AS ' . $columns[$key]->getColumnName(); |
|
249 | + $result[]='NULL AS '.$columns[$key]->getColumnName(); |
|
250 | 250 | else |
251 | - $result[] = 'NULL' . (is_string($key) ? (' AS ' . (string)$key) : ''); |
|
251 | + $result[]='NULL'.(is_string($key) ? (' AS '.(string) $key) : ''); |
|
252 | 252 | continue; |
253 | 253 | } |
254 | 254 | |
255 | - if(strpos($value, '(') !== false && strpos($value, ')') !== false) { |
|
255 | + if(strpos($value, '(')!==false && strpos($value, ')')!==false) { |
|
256 | 256 | if($k) |
257 | - $result[] = $value . ' AS ' . $columns[$key]->getColumnName(); |
|
257 | + $result[]=$value.' AS '.$columns[$key]->getColumnName(); |
|
258 | 258 | else |
259 | - $result[] = $value . (is_string($key) ? (' AS ' . (string)$key) : ''); |
|
259 | + $result[]=$value.(is_string($key) ? (' AS '.(string) $key) : ''); |
|
260 | 260 | continue; |
261 | 261 | } |
262 | 262 | |
263 | - if($v && $key == $value) { |
|
264 | - $result[] = $columns[$value]->getColumnName(); |
|
263 | + if($v && $key==$value) { |
|
264 | + $result[]=$columns[$value]->getColumnName(); |
|
265 | 265 | continue; |
266 | 266 | } |
267 | 267 | |
268 | - if($k && $value == null) { |
|
269 | - $result[] = $columns[$key]->getColumnName(); |
|
268 | + if($k && $value==null) { |
|
269 | + $result[]=$columns[$key]->getColumnName(); |
|
270 | 270 | continue; |
271 | 271 | } |
272 | 272 | |
273 | 273 | if(is_string($key) && $v) { |
274 | - $result[] = $columns[$value]->getColumnName() . ' AS ' . $key; |
|
274 | + $result[]=$columns[$value]->getColumnName().' AS '.$key; |
|
275 | 275 | continue; |
276 | 276 | } |
277 | 277 | |
278 | 278 | if(is_numeric($value) && $k) { |
279 | - $result[] = $value . ' AS ' . $columns[$key]->getColumnName(); |
|
279 | + $result[]=$value.' AS '.$columns[$key]->getColumnName(); |
|
280 | 280 | continue; |
281 | 281 | } |
282 | 282 | |
283 | 283 | if(is_string($value) && $k) { |
284 | - $result[] = $this->getDbConnection()->quoteString($value) . ' AS ' . $columns[$key]->getColumnName(); |
|
284 | + $result[]=$this->getDbConnection()->quoteString($value).' AS '.$columns[$key]->getColumnName(); |
|
285 | 285 | continue; |
286 | 286 | } |
287 | 287 | |
288 | 288 | if(!$v && !$k && is_int($key)) { |
289 | - $result[] = is_numeric($value) ? $value : $this->getDbConnection()->quoteString((string)$value); |
|
289 | + $result[]=is_numeric($value) ? $value : $this->getDbConnection()->quoteString((string) $value); |
|
290 | 290 | continue; |
291 | 291 | } |
292 | 292 | |
293 | - $result[] = (is_numeric($value) ? $value : $this->getDbConnection()->quoteString((string)$value)) . ' AS ' . $key; |
|
293 | + $result[]=(is_numeric($value) ? $value : $this->getDbConnection()->quoteString((string) $value)).' AS '.$key; |
|
294 | 294 | } |
295 | 295 | } |
296 | 296 | |
297 | - if($data === null || count($result) == 0 || $bHasWildcard) |
|
298 | - $result = $result = array_merge($this->getTableInfo()->getColumnNames(), $result); |
|
297 | + if($data===null || count($result)==0 || $bHasWildcard) |
|
298 | + $result=$result=array_merge($this->getTableInfo()->getColumnNames(), $result); |
|
299 | 299 | |
300 | 300 | return $result; |
301 | 301 | } |
@@ -307,23 +307,23 @@ discard block |
||
307 | 307 | * @param array condition parameters. |
308 | 308 | * @return TDbCommand query command. |
309 | 309 | */ |
310 | - public function createFindCommand($where = '1=1', $parameters = [], $ordering = [], $limit = -1, $offset = -1, $select = '*') |
|
310 | + public function createFindCommand($where='1=1', $parameters=[], $ordering=[], $limit=-1, $offset=-1, $select='*') |
|
311 | 311 | { |
312 | - $table = $this->getTableInfo()->getTableFullName(); |
|
313 | - $fields = implode(', ', $this -> getSelectFieldList($select)); |
|
314 | - $sql = "SELECT {$fields} FROM {$table}"; |
|
312 | + $table=$this->getTableInfo()->getTableFullName(); |
|
313 | + $fields=implode(', ', $this -> getSelectFieldList($select)); |
|
314 | + $sql="SELECT {$fields} FROM {$table}"; |
|
315 | 315 | if(!empty($where)) |
316 | - $sql .= " WHERE {$where}"; |
|
316 | + $sql.=" WHERE {$where}"; |
|
317 | 317 | return $this->applyCriterias($sql, $parameters, $ordering, $limit, $offset); |
318 | 318 | } |
319 | 319 | |
320 | - public function applyCriterias($sql, $parameters = [], $ordering = [], $limit = -1, $offset = -1) |
|
320 | + public function applyCriterias($sql, $parameters=[], $ordering=[], $limit=-1, $offset=-1) |
|
321 | 321 | { |
322 | 322 | if(count($ordering) > 0) |
323 | - $sql = $this->applyOrdering($sql, $ordering); |
|
323 | + $sql=$this->applyOrdering($sql, $ordering); |
|
324 | 324 | if($limit >= 0 || $offset >= 0) |
325 | - $sql = $this->applyLimitOffset($sql, $limit, $offset); |
|
326 | - $command = $this->createCommand($sql); |
|
325 | + $sql=$this->applyLimitOffset($sql, $limit, $offset); |
|
326 | + $command=$this->createCommand($sql); |
|
327 | 327 | $this->bindArrayValues($command, $parameters); |
328 | 328 | return $command; |
329 | 329 | } |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | * @param array binding parameters. |
335 | 335 | * @return TDbCommand count command. |
336 | 336 | */ |
337 | - public function createCountCommand($where = '1=1', $parameters = [], $ordering = [], $limit = -1, $offset = -1) |
|
337 | + public function createCountCommand($where='1=1', $parameters=[], $ordering=[], $limit=-1, $offset=-1) |
|
338 | 338 | { |
339 | 339 | return $this->createFindCommand($where, $parameters, $ordering, $limit, $offset, 'COUNT(*)'); |
340 | 340 | } |
@@ -347,12 +347,12 @@ discard block |
||
347 | 347 | * @param array delete parameters. |
348 | 348 | * @return TDbCommand delete command. |
349 | 349 | */ |
350 | - public function createDeleteCommand($where, $parameters = []) |
|
350 | + public function createDeleteCommand($where, $parameters=[]) |
|
351 | 351 | { |
352 | - $table = $this->getTableInfo()->getTableFullName(); |
|
353 | - if (!empty($where)) |
|
354 | - $where = ' WHERE ' . $where; |
|
355 | - $command = $this->createCommand("DELETE FROM {$table}" . $where); |
|
352 | + $table=$this->getTableInfo()->getTableFullName(); |
|
353 | + if(!empty($where)) |
|
354 | + $where=' WHERE '.$where; |
|
355 | + $command=$this->createCommand("DELETE FROM {$table}".$where); |
|
356 | 356 | $this->bindArrayValues($command, $parameters); |
357 | 357 | return $command; |
358 | 358 | } |
@@ -367,9 +367,9 @@ discard block |
||
367 | 367 | */ |
368 | 368 | public function createInsertCommand($data) |
369 | 369 | { |
370 | - $table = $this->getTableInfo()->getTableFullName(); |
|
371 | - list($fields, $bindings) = $this->getInsertFieldBindings($data); |
|
372 | - $command = $this->createCommand("INSERT INTO {$table}({$fields}) VALUES ($bindings)"); |
|
370 | + $table=$this->getTableInfo()->getTableFullName(); |
|
371 | + list($fields, $bindings)=$this->getInsertFieldBindings($data); |
|
372 | + $command=$this->createCommand("INSERT INTO {$table}({$fields}) VALUES ($bindings)"); |
|
373 | 373 | $this->bindColumnValues($command, $data); |
374 | 374 | return $command; |
375 | 375 | } |
@@ -382,17 +382,17 @@ discard block |
||
382 | 382 | * @param array update parameters. |
383 | 383 | * @return TDbCommand update command. |
384 | 384 | */ |
385 | - public function createUpdateCommand($data, $where, $parameters = []) |
|
385 | + public function createUpdateCommand($data, $where, $parameters=[]) |
|
386 | 386 | { |
387 | - $table = $this->getTableInfo()->getTableFullName(); |
|
387 | + $table=$this->getTableInfo()->getTableFullName(); |
|
388 | 388 | if($this->hasIntegerKey($parameters)) |
389 | - $fields = implode(', ', $this->getColumnBindings($data, true)); |
|
389 | + $fields=implode(', ', $this->getColumnBindings($data, true)); |
|
390 | 390 | else |
391 | - $fields = implode(', ', $this->getColumnBindings($data)); |
|
391 | + $fields=implode(', ', $this->getColumnBindings($data)); |
|
392 | 392 | |
393 | - if (!empty($where)) |
|
394 | - $where = ' WHERE ' . $where; |
|
395 | - $command = $this->createCommand("UPDATE {$table} SET {$fields}" . $where); |
|
393 | + if(!empty($where)) |
|
394 | + $where=' WHERE '.$where; |
|
395 | + $command=$this->createCommand("UPDATE {$table} SET {$fields}".$where); |
|
396 | 396 | $this->bindArrayValues($command, array_merge($data, $parameters)); |
397 | 397 | return $command; |
398 | 398 | } |
@@ -404,11 +404,11 @@ discard block |
||
404 | 404 | */ |
405 | 405 | protected function getInsertFieldBindings($values) |
406 | 406 | { |
407 | - $fields = []; $bindings = []; |
|
407 | + $fields=[]; $bindings=[]; |
|
408 | 408 | foreach(array_keys($values) as $name) |
409 | 409 | { |
410 | - $fields[] = $this->getTableInfo()->getColumn($name)->getColumnName(); |
|
411 | - $bindings[] = ':' . $name; |
|
410 | + $fields[]=$this->getTableInfo()->getColumn($name)->getColumnName(); |
|
411 | + $bindings[]=':'.$name; |
|
412 | 412 | } |
413 | 413 | return [implode(', ', $fields), implode(', ', $bindings)]; |
414 | 414 | } |
@@ -419,13 +419,13 @@ discard block |
||
419 | 419 | * @param boolean true to bind as position values. |
420 | 420 | * @return string update column names with corresponding binding substrings. |
421 | 421 | */ |
422 | - protected function getColumnBindings($values, $position = false) |
|
422 | + protected function getColumnBindings($values, $position=false) |
|
423 | 423 | { |
424 | - $bindings = []; |
|
424 | + $bindings=[]; |
|
425 | 425 | foreach(array_keys($values) as $name) |
426 | 426 | { |
427 | - $column = $this->getTableInfo()->getColumn($name)->getColumnName(); |
|
428 | - $bindings[] = $position ? $column . ' = ?' : $column . ' = :' . $name; |
|
427 | + $column=$this->getTableInfo()->getColumn($name)->getColumnName(); |
|
428 | + $bindings[]=$position ? $column.' = ?' : $column.' = :'.$name; |
|
429 | 429 | } |
430 | 430 | return $bindings; |
431 | 431 | } |
@@ -449,11 +449,11 @@ discard block |
||
449 | 449 | { |
450 | 450 | foreach($values as $name => $value) |
451 | 451 | { |
452 | - $column = $this->getTableInfo()->getColumn($name); |
|
453 | - if($value === null && $column->getAllowNull()) |
|
454 | - $command->bindValue(':' . $name, null, PDO::PARAM_NULL); |
|
452 | + $column=$this->getTableInfo()->getColumn($name); |
|
453 | + if($value===null && $column->getAllowNull()) |
|
454 | + $command->bindValue(':'.$name, null, PDO::PARAM_NULL); |
|
455 | 455 | else |
456 | - $command->bindValue(':' . $name, $value, $column->getPdoType()); |
|
456 | + $command->bindValue(':'.$name, $value, $column->getPdoType()); |
|
457 | 457 | } |
458 | 458 | } |
459 | 459 | |
@@ -465,15 +465,15 @@ discard block |
||
465 | 465 | { |
466 | 466 | if($this->hasIntegerKey($values)) |
467 | 467 | { |
468 | - $values = array_values($values); |
|
469 | - for($i = 0, $max = count($values); $i < $max; $i++) |
|
468 | + $values=array_values($values); |
|
469 | + for($i=0, $max=count($values); $i < $max; $i++) |
|
470 | 470 | $command->bindValue($i + 1, $values[$i], $this->getPdoType($values[$i])); |
471 | 471 | } |
472 | 472 | else |
473 | 473 | { |
474 | 474 | foreach($values as $name => $value) |
475 | 475 | { |
476 | - $prop = $name[0] === ':' ? $name : ':' . $name; |
|
476 | + $prop=$name[0]===':' ? $name : ':'.$name; |
|
477 | 477 | $command->bindValue($prop, $value, $this->getPdoType($value)); |
478 | 478 | } |
479 | 479 | } |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | { |
503 | 503 | foreach($array as $k => $v) |
504 | 504 | { |
505 | - if(gettype($k) === 'integer') |
|
505 | + if(gettype($k)==='integer') |
|
506 | 506 | return true; |
507 | 507 | } |
508 | 508 | return false; |
@@ -468,8 +468,7 @@ |
||
468 | 468 | $values = array_values($values); |
469 | 469 | for($i = 0, $max = count($values); $i < $max; $i++) |
470 | 470 | $command->bindValue($i + 1, $values[$i], $this->getPdoType($values[$i])); |
471 | - } |
|
472 | - else |
|
471 | + } else |
|
473 | 472 | { |
474 | 473 | foreach($values as $name => $value) |
475 | 474 | { |
@@ -84,6 +84,7 @@ discard block |
||
84 | 84 | * Updates the table with new data. |
85 | 85 | * @param array date for update. |
86 | 86 | * @param TSqlCriteria update conditions and parameters. |
87 | + * @param TSqlCriteria $criteria |
|
87 | 88 | * @return integer number of records affected. |
88 | 89 | */ |
89 | 90 | public function update($data, $criteria) |
@@ -369,7 +370,8 @@ discard block |
||
369 | 370 | * @param string __call method name |
370 | 371 | * @param string criteria conditions |
371 | 372 | * @param array method arguments |
372 | - * @return TActiveRecordCriteria criteria created from the method name and its arguments. |
|
373 | + * @param string $condition |
|
374 | + * @return TSqlCriteria criteria created from the method name and its arguments. |
|
373 | 375 | */ |
374 | 376 | public function createCriteriaFromString($method, $condition, $args) |
375 | 377 | { |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function __construct($builder) |
46 | 46 | { |
47 | - $this->_builder = $builder; |
|
47 | + $this->_builder=$builder; |
|
48 | 48 | } |
49 | 49 | /** |
50 | 50 | * @return TDbTableInfo |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function delete($criteria) |
76 | 76 | { |
77 | - $where = $criteria->getCondition(); |
|
78 | - $parameters = $criteria->getParameters()->toArray(); |
|
79 | - $command = $this->getBuilder()->createDeleteCommand($where, $parameters); |
|
77 | + $where=$criteria->getCondition(); |
|
78 | + $parameters=$criteria->getParameters()->toArray(); |
|
79 | + $command=$this->getBuilder()->createDeleteCommand($where, $parameters); |
|
80 | 80 | $this->onCreateCommand($command, $criteria); |
81 | 81 | $command->prepare(); |
82 | 82 | return $command->execute(); |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function update($data, $criteria) |
91 | 91 | { |
92 | - $where = $criteria->getCondition(); |
|
93 | - $parameters = $criteria->getParameters()->toArray(); |
|
94 | - $command = $this->getBuilder()->createUpdateCommand($data, $where, $parameters); |
|
92 | + $where=$criteria->getCondition(); |
|
93 | + $parameters=$criteria->getParameters()->toArray(); |
|
94 | + $command=$this->getBuilder()->createUpdateCommand($data, $where, $parameters); |
|
95 | 95 | $this->onCreateCommand($command, $criteria); |
96 | 96 | $command->prepare(); |
97 | 97 | return $this->onExecuteCommand($command, $command->execute()); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function updateByPk($data, $keys) |
105 | 105 | { |
106 | - list($where, $parameters) = $this->getPrimaryKeyCondition((array)$keys); |
|
106 | + list($where, $parameters)=$this->getPrimaryKeyCondition((array) $keys); |
|
107 | 107 | return $this->update($data, new TSqlCriteria($where, $parameters)); |
108 | 108 | } |
109 | 109 | /** |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function find($criteria) |
115 | 115 | { |
116 | - $command = $this->getFindCommand($criteria); |
|
116 | + $command=$this->getFindCommand($criteria); |
|
117 | 117 | return $this->onExecuteCommand($command, $command->queryRow()); |
118 | 118 | } |
119 | 119 | /** |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | */ |
124 | 124 | public function findAll($criteria) |
125 | 125 | { |
126 | - $command = $this->getFindCommand($criteria); |
|
126 | + $command=$this->getFindCommand($criteria); |
|
127 | 127 | return $this->onExecuteCommand($command, $command->query()); |
128 | 128 | } |
129 | 129 | /** |
@@ -133,15 +133,15 @@ discard block |
||
133 | 133 | */ |
134 | 134 | protected function getFindCommand($criteria) |
135 | 135 | { |
136 | - if($criteria === null) |
|
136 | + if($criteria===null) |
|
137 | 137 | return $this->getBuilder()->createFindCommand(); |
138 | - $where = $criteria->getCondition(); |
|
139 | - $parameters = $criteria->getParameters()->toArray(); |
|
140 | - $ordering = $criteria->getOrdersBy(); |
|
141 | - $limit = $criteria->getLimit(); |
|
142 | - $offset = $criteria->getOffset(); |
|
143 | - $select = $criteria->getSelect(); |
|
144 | - $command = $this->getBuilder()->createFindCommand($where, $parameters, $ordering, $limit, $offset, $select); |
|
138 | + $where=$criteria->getCondition(); |
|
139 | + $parameters=$criteria->getParameters()->toArray(); |
|
140 | + $ordering=$criteria->getOrdersBy(); |
|
141 | + $limit=$criteria->getLimit(); |
|
142 | + $offset=$criteria->getOffset(); |
|
143 | + $select=$criteria->getSelect(); |
|
144 | + $command=$this->getBuilder()->createFindCommand($where, $parameters, $ordering, $limit, $offset, $select); |
|
145 | 145 | $this->onCreateCommand($command, $criteria); |
146 | 146 | return $command; |
147 | 147 | } |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function findByPk($keys) |
153 | 153 | { |
154 | - if($keys === null) |
|
154 | + if($keys===null) |
|
155 | 155 | return null; |
156 | - list($where, $parameters) = $this->getPrimaryKeyCondition((array)$keys); |
|
157 | - $command = $this->getBuilder()->createFindCommand($where, $parameters); |
|
156 | + list($where, $parameters)=$this->getPrimaryKeyCondition((array) $keys); |
|
157 | + $command=$this->getBuilder()->createFindCommand($where, $parameters); |
|
158 | 158 | $this->onCreateCommand($command, new TSqlCriteria($where, $parameters)); |
159 | 159 | return $this->onExecuteCommand($command, $command->queryRow()); |
160 | 160 | } |
@@ -164,19 +164,19 @@ discard block |
||
164 | 164 | */ |
165 | 165 | public function findAllByPk($keys) |
166 | 166 | { |
167 | - $where = $this->getCompositeKeyCondition((array)$keys); |
|
168 | - $command = $this->getBuilder()->createFindCommand($where); |
|
167 | + $where=$this->getCompositeKeyCondition((array) $keys); |
|
168 | + $command=$this->getBuilder()->createFindCommand($where); |
|
169 | 169 | $this->onCreateCommand($command, new TSqlCriteria($where, $keys)); |
170 | 170 | return $this->onExecuteCommand($command, $command->query()); |
171 | 171 | } |
172 | 172 | public function findAllByIndex($criteria, $fields, $values) |
173 | 173 | { |
174 | - $index = $this->getIndexKeyCondition($this->getTableInfo(), $fields, $values); |
|
175 | - if(strlen($where = $criteria->getCondition()) > 0) |
|
174 | + $index=$this->getIndexKeyCondition($this->getTableInfo(), $fields, $values); |
|
175 | + if(strlen($where=$criteria->getCondition()) > 0) |
|
176 | 176 | $criteria->setCondition("({$index}) AND ({$where})"); |
177 | 177 | else |
178 | 178 | $criteria->setCondition($index); |
179 | - $command = $this->getFindCommand($criteria); |
|
179 | + $command=$this->getFindCommand($criteria); |
|
180 | 180 | $this->onCreateCommand($command, $criteria); |
181 | 181 | return $this->onExecuteCommand($command, $command->query()); |
182 | 182 | } |
@@ -187,10 +187,10 @@ discard block |
||
187 | 187 | */ |
188 | 188 | public function deleteByPk($keys) |
189 | 189 | { |
190 | - if(count($keys) == 0) |
|
190 | + if(count($keys)==0) |
|
191 | 191 | return 0; |
192 | - $where = $this->getCompositeKeyCondition((array)$keys); |
|
193 | - $command = $this->getBuilder()->createDeleteCommand($where); |
|
192 | + $where=$this->getCompositeKeyCondition((array) $keys); |
|
193 | + $command=$this->getBuilder()->createDeleteCommand($where); |
|
194 | 194 | $this->onCreateCommand($command, new TSqlCriteria($where, $keys)); |
195 | 195 | $command->prepare(); |
196 | 196 | return $this->onExecuteCommand($command, $command->execute()); |
@@ -198,13 +198,13 @@ discard block |
||
198 | 198 | |
199 | 199 | public function getIndexKeyCondition($table, $fields, $values) |
200 | 200 | { |
201 | - if (!count($values)) |
|
201 | + if(!count($values)) |
|
202 | 202 | return 'FALSE'; |
203 | - $columns = []; |
|
204 | - $tableName = $table->getTableFullName(); |
|
203 | + $columns=[]; |
|
204 | + $tableName=$table->getTableFullName(); |
|
205 | 205 | foreach($fields as $field) |
206 | - $columns[] = $tableName . '.' . $table->getColumn($field)->getColumnName(); |
|
207 | - return '(' . implode(', ', $columns) . ') IN ' . $this->quoteTuple($values); |
|
206 | + $columns[]=$tableName.'.'.$table->getColumn($field)->getColumnName(); |
|
207 | + return '('.implode(', ', $columns).') IN '.$this->quoteTuple($values); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -214,21 +214,21 @@ discard block |
||
214 | 214 | */ |
215 | 215 | protected function getCompositeKeyCondition($values) |
216 | 216 | { |
217 | - $primary = $this->getTableInfo()->getPrimaryKeys(); |
|
218 | - $count = count($primary); |
|
219 | - if($count === 0) |
|
217 | + $primary=$this->getTableInfo()->getPrimaryKeys(); |
|
218 | + $count=count($primary); |
|
219 | + if($count===0) |
|
220 | 220 | { |
221 | 221 | throw new TDbException('dbtablegateway_no_primary_key_found', |
222 | 222 | $this->getTableInfo()->getTableFullName()); |
223 | 223 | } |
224 | - if(!is_array($values) || count($values) === 0) |
|
224 | + if(!is_array($values) || count($values)===0) |
|
225 | 225 | { |
226 | 226 | throw new TDbException('dbtablegateway_missing_pk_values', |
227 | 227 | $this->getTableInfo()->getTableFullName()); |
228 | 228 | } |
229 | 229 | if($count > 1 && (!isset($values[0]) || !is_array($values[0]))) |
230 | - $values = [$values]; |
|
231 | - if($count > 1 && count($values[0]) !== $count) |
|
230 | + $values=[$values]; |
|
231 | + if($count > 1 && count($values[0])!==$count) |
|
232 | 232 | { |
233 | 233 | throw new TDbException('dbtablegateway_pk_value_count_mismatch', |
234 | 234 | $this->getTableInfo()->getTableFullName()); |
@@ -243,11 +243,11 @@ discard block |
||
243 | 243 | */ |
244 | 244 | protected function quoteTuple($array) |
245 | 245 | { |
246 | - $conn = $this->getDbConnection(); |
|
247 | - $data = []; |
|
246 | + $conn=$this->getDbConnection(); |
|
247 | + $data=[]; |
|
248 | 248 | foreach($array as $k => $v) |
249 | - $data[] = is_array($v) ? $this->quoteTuple($v) : $conn->quoteString($v); |
|
250 | - return '(' . implode(', ', $data) . ')'; |
|
249 | + $data[]=is_array($v) ? $this->quoteTuple($v) : $conn->quoteString($v); |
|
250 | + return '('.implode(', ', $data).')'; |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
@@ -257,20 +257,20 @@ discard block |
||
257 | 257 | */ |
258 | 258 | protected function getPrimaryKeyCondition($values) |
259 | 259 | { |
260 | - $primary = $this->getTableInfo()->getPrimaryKeys(); |
|
261 | - if(count($primary) === 0) |
|
260 | + $primary=$this->getTableInfo()->getPrimaryKeys(); |
|
261 | + if(count($primary)===0) |
|
262 | 262 | { |
263 | 263 | throw new TDbException('dbtablegateway_no_primary_key_found', |
264 | 264 | $this->getTableInfo()->getTableFullName()); |
265 | 265 | } |
266 | - $criteria = []; |
|
267 | - $bindings = []; |
|
268 | - $i = 0; |
|
266 | + $criteria=[]; |
|
267 | + $bindings=[]; |
|
268 | + $i=0; |
|
269 | 269 | foreach($primary as $key) |
270 | 270 | { |
271 | - $column = $this->getTableInfo()->getColumn($key)->getColumnName(); |
|
272 | - $criteria[] = $column . ' = :' . $key; |
|
273 | - $bindings[$key] = isset($values[$key])?$values[$key]:$values[$i++]; |
|
271 | + $column=$this->getTableInfo()->getColumn($key)->getColumnName(); |
|
272 | + $criteria[]=$column.' = :'.$key; |
|
273 | + $bindings[$key]=isset($values[$key]) ? $values[$key] : $values[$i++]; |
|
274 | 274 | } |
275 | 275 | return [implode(' AND ', $criteria), $bindings]; |
276 | 276 | } |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | */ |
283 | 283 | public function findBySql($criteria) |
284 | 284 | { |
285 | - $command = $this->getSqlCommand($criteria); |
|
285 | + $command=$this->getSqlCommand($criteria); |
|
286 | 286 | return $this->onExecuteCommand($command, $command->queryRow()); |
287 | 287 | } |
288 | 288 | |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | */ |
294 | 294 | public function findAllBySql($criteria) |
295 | 295 | { |
296 | - $command = $this->getSqlCommand($criteria); |
|
296 | + $command=$this->getSqlCommand($criteria); |
|
297 | 297 | return $this->onExecuteCommand($command, $command->query()); |
298 | 298 | } |
299 | 299 | |
@@ -304,15 +304,15 @@ discard block |
||
304 | 304 | */ |
305 | 305 | protected function getSqlCommand($criteria) |
306 | 306 | { |
307 | - $sql = $criteria->getCondition(); |
|
308 | - $ordering = $criteria->getOrdersBy(); |
|
309 | - $limit = $criteria->getLimit(); |
|
310 | - $offset = $criteria->getOffset(); |
|
307 | + $sql=$criteria->getCondition(); |
|
308 | + $ordering=$criteria->getOrdersBy(); |
|
309 | + $limit=$criteria->getLimit(); |
|
310 | + $offset=$criteria->getOffset(); |
|
311 | 311 | if(count($ordering) > 0) |
312 | - $sql = $this->getBuilder()->applyOrdering($sql, $ordering); |
|
312 | + $sql=$this->getBuilder()->applyOrdering($sql, $ordering); |
|
313 | 313 | if($limit >= 0 || $offset >= 0) |
314 | - $sql = $this->getBuilder()->applyLimitOffset($sql, $limit, $offset); |
|
315 | - $command = $this->getBuilder()->createCommand($sql); |
|
314 | + $sql=$this->getBuilder()->applyLimitOffset($sql, $limit, $offset); |
|
315 | + $command=$this->getBuilder()->createCommand($sql); |
|
316 | 316 | $this->getBuilder()->bindArrayValues($command, $criteria->getParameters()->toArray()); |
317 | 317 | $this->onCreateCommand($command, $criteria); |
318 | 318 | return $command; |
@@ -324,16 +324,16 @@ discard block |
||
324 | 324 | */ |
325 | 325 | public function count($criteria) |
326 | 326 | { |
327 | - if($criteria === null) |
|
328 | - return (int)$this->getBuilder()->createCountCommand()->queryScalar(); |
|
329 | - $where = $criteria->getCondition(); |
|
330 | - $parameters = $criteria->getParameters()->toArray(); |
|
331 | - $ordering = $criteria->getOrdersBy(); |
|
332 | - $limit = $criteria->getLimit(); |
|
333 | - $offset = $criteria->getOffset(); |
|
334 | - $command = $this->getBuilder()->createCountCommand($where, $parameters, $ordering, $limit, $offset); |
|
327 | + if($criteria===null) |
|
328 | + return (int) $this->getBuilder()->createCountCommand()->queryScalar(); |
|
329 | + $where=$criteria->getCondition(); |
|
330 | + $parameters=$criteria->getParameters()->toArray(); |
|
331 | + $ordering=$criteria->getOrdersBy(); |
|
332 | + $limit=$criteria->getLimit(); |
|
333 | + $offset=$criteria->getOffset(); |
|
334 | + $command=$this->getBuilder()->createCountCommand($where, $parameters, $ordering, $limit, $offset); |
|
335 | 335 | $this->onCreateCommand($command, $criteria); |
336 | - return $this->onExecuteCommand($command, (int)$command->queryScalar()); |
|
336 | + return $this->onExecuteCommand($command, (int) $command->queryScalar()); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | /** |
@@ -345,13 +345,13 @@ discard block |
||
345 | 345 | */ |
346 | 346 | public function insert($data) |
347 | 347 | { |
348 | - $command = $this->getBuilder()->createInsertCommand($data); |
|
348 | + $command=$this->getBuilder()->createInsertCommand($data); |
|
349 | 349 | $this->onCreateCommand($command, new TSqlCriteria(null, $data)); |
350 | 350 | $command->prepare(); |
351 | 351 | if($this->onExecuteCommand($command, $command->execute()) > 0) |
352 | 352 | { |
353 | - $value = $this->getLastInsertId(); |
|
354 | - return $value !== null ? $value : true; |
|
353 | + $value=$this->getLastInsertId(); |
|
354 | + return $value!==null ? $value : true; |
|
355 | 355 | } |
356 | 356 | return false; |
357 | 357 | } |
@@ -374,8 +374,8 @@ discard block |
||
374 | 374 | */ |
375 | 375 | public function createCriteriaFromString($method, $condition, $args) |
376 | 376 | { |
377 | - $fields = $this->extractMatchingConditions($method, $condition); |
|
378 | - $args = count($args) === 1 && is_array($args[0]) ? $args[0] : $args; |
|
377 | + $fields=$this->extractMatchingConditions($method, $condition); |
|
378 | + $args=count($args)===1 && is_array($args[0]) ? $args[0] : $args; |
|
379 | 379 | if(count($fields) > count($args)) |
380 | 380 | { |
381 | 381 | throw new TDbException('dbtablegateway_mismatch_args_exception', |
@@ -393,25 +393,25 @@ discard block |
||
393 | 393 | */ |
394 | 394 | protected function extractMatchingConditions($method, $condition) |
395 | 395 | { |
396 | - $table = $this->getTableInfo(); |
|
397 | - $columns = $table->getLowerCaseColumnNames(); |
|
398 | - $regexp = '/(' . implode('|', array_keys($columns)) . ')(and|_and_|or|_or_)?/i'; |
|
399 | - $matches = []; |
|
396 | + $table=$this->getTableInfo(); |
|
397 | + $columns=$table->getLowerCaseColumnNames(); |
|
398 | + $regexp='/('.implode('|', array_keys($columns)).')(and|_and_|or|_or_)?/i'; |
|
399 | + $matches=[]; |
|
400 | 400 | if(!preg_match_all($regexp, strtolower($condition), $matches, PREG_SET_ORDER)) |
401 | 401 | { |
402 | 402 | throw new TDbException('dbtablegateway_mismatch_column_name', |
403 | 403 | $method, implode(', ', $columns), $table->getTableFullName()); |
404 | 404 | } |
405 | 405 | |
406 | - $fields = []; |
|
406 | + $fields=[]; |
|
407 | 407 | foreach($matches as $match) |
408 | 408 | { |
409 | - $key = $columns[$match[1]]; |
|
410 | - $column = $table->getColumn($key)->getColumnName(); |
|
411 | - $sql = $column . ' = ? '; |
|
409 | + $key=$columns[$match[1]]; |
|
410 | + $column=$table->getColumn($key)->getColumnName(); |
|
411 | + $sql=$column.' = ? '; |
|
412 | 412 | if(count($match) > 2) |
413 | - $sql .= strtoupper(str_replace('_', '', $match[2])); |
|
414 | - $fields[] = $sql; |
|
413 | + $sql.=strtoupper(str_replace('_', '', $match[2])); |
|
414 | + $fields[]=$sql; |
|
415 | 415 | } |
416 | 416 | return $fields; |
417 | 417 | } |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | */ |
441 | 441 | public function onExecuteCommand($command, $result) |
442 | 442 | { |
443 | - $parameter = new TDataGatewayResultEventParameter($command, $result); |
|
443 | + $parameter=new TDataGatewayResultEventParameter($command, $result); |
|
444 | 444 | $this->raiseEvent('OnExecuteCommand', $this, $parameter); |
445 | 445 | return $parameter->getResult(); |
446 | 446 | } |
@@ -33,7 +33,7 @@ |
||
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
36 | - * @param string serialized object |
|
36 | + * @param string string object |
|
37 | 37 | * @return string crc32 hash of the serialized object. |
38 | 38 | */ |
39 | 39 | protected function generateKey($string) |
@@ -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 | /** |
@@ -149,6 +149,7 @@ discard block |
||
149 | 149 | |
150 | 150 | /** |
151 | 151 | * @param TSqlMapCacheKey|string cache key |
152 | + * @param string $key |
|
152 | 153 | * @return mixed cached value. |
153 | 154 | */ |
154 | 155 | public function get($key) |
@@ -167,6 +168,7 @@ discard block |
||
167 | 168 | /** |
168 | 169 | * @param TSqlMapCacheKey|string cache key |
169 | 170 | * @param mixed value to be cached. |
171 | + * @param string $key |
|
170 | 172 | */ |
171 | 173 | public function set($key, $value) |
172 | 174 | { |
@@ -178,7 +180,7 @@ discard block |
||
178 | 180 | } |
179 | 181 | |
180 | 182 | /** |
181 | - * @return float cache hit ratio. |
|
183 | + * @return integer cache hit ratio. |
|
182 | 184 | */ |
183 | 185 | public function getHitRatio() |
184 | 186 | { |
@@ -38,18 +38,18 @@ discard block |
||
38 | 38 | class TSqlMapCacheModel extends \Prado\TComponent |
39 | 39 | { |
40 | 40 | private $_cache; |
41 | - private $_hits = 0; |
|
42 | - private $_requests = 0; |
|
41 | + private $_hits=0; |
|
42 | + private $_requests=0; |
|
43 | 43 | private $_id; |
44 | - private $_implementation = TSqlMapCacheTypes::Basic; |
|
45 | - private $_properties = []; |
|
46 | - private $_flushInterval = 0; |
|
44 | + private $_implementation=TSqlMapCacheTypes::Basic; |
|
45 | + private $_properties=[]; |
|
46 | + private $_flushInterval=0; |
|
47 | 47 | |
48 | - private static $_cacheTypes = []; |
|
48 | + private static $_cacheTypes=[]; |
|
49 | 49 | |
50 | 50 | public static function registerCacheType($type, $className) |
51 | 51 | { |
52 | - self::$_cacheTypes[$type] = $className; |
|
52 | + self::$_cacheTypes[$type]=$className; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function setID($value) |
67 | 67 | { |
68 | - $this->_id = $value; |
|
68 | + $this->_id=$value; |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -81,10 +81,10 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function setImplementation($value) |
83 | 83 | { |
84 | - if (isset(self::$_cacheTypes[$value])) |
|
85 | - $this->_implementation = $value; |
|
84 | + if(isset(self::$_cacheTypes[$value])) |
|
85 | + $this->_implementation=$value; |
|
86 | 86 | else |
87 | - $this->_implementation = TPropertyValue::ensureEnum($value, 'Prado\\Data\\SqlMap\\Configuration\\TSqlMapCacheTypes'); |
|
87 | + $this->_implementation=TPropertyValue::ensureEnum($value, 'Prado\\Data\\SqlMap\\Configuration\\TSqlMapCacheTypes'); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function setFlushInterval($value) |
94 | 94 | { |
95 | - $this->_flushInterval = TPropertyValue::ensureInteger($value); |
|
95 | + $this->_flushInterval=TPropertyValue::ensureInteger($value); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -107,12 +107,12 @@ discard block |
||
107 | 107 | * Initialize the cache implementation, sets the actual cache contain if supplied. |
108 | 108 | * @param ISqLMapCache cache implementation instance. |
109 | 109 | */ |
110 | - public function initialize($cache = null) |
|
110 | + public function initialize($cache=null) |
|
111 | 111 | { |
112 | - if($cache === null) |
|
113 | - $this->_cache = Prado::createComponent($this->getImplementationClass(), $this); |
|
112 | + if($cache===null) |
|
113 | + $this->_cache=Prado::createComponent($this->getImplementationClass(), $this); |
|
114 | 114 | else |
115 | - $this->_cache = $cache; |
|
115 | + $this->_cache=$cache; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function getImplementationClass() |
122 | 122 | { |
123 | - $implementation = $this->_implementation; |
|
124 | - if (isset(self::$_cacheTypes[$implementation])) return self::$_cacheTypes[$implementation]; |
|
123 | + $implementation=$this->_implementation; |
|
124 | + if(isset(self::$_cacheTypes[$implementation])) return self::$_cacheTypes[$implementation]; |
|
125 | 125 | |
126 | 126 | switch(TPropertyValue::ensureEnum($implementation, 'Prado\\Data\\SqlMap\\Configuration\\TSqlMapCacheTypes')) |
127 | 127 | { |
@@ -155,12 +155,12 @@ discard block |
||
155 | 155 | public function get($key) |
156 | 156 | { |
157 | 157 | if($key instanceof TSqlMapCacheKey) |
158 | - $key = $key->getHash(); |
|
158 | + $key=$key->getHash(); |
|
159 | 159 | |
160 | 160 | //if flush ? |
161 | - $value = $this->_cache->get($key); |
|
161 | + $value=$this->_cache->get($key); |
|
162 | 162 | $this->_requests++; |
163 | - if($value !== null) |
|
163 | + if($value!==null) |
|
164 | 164 | $this->_hits++; |
165 | 165 | return $value; |
166 | 166 | } |
@@ -172,9 +172,9 @@ discard block |
||
172 | 172 | public function set($key, $value) |
173 | 173 | { |
174 | 174 | if($key instanceof TSqlMapCacheKey) |
175 | - $key = $key->getHash(); |
|
175 | + $key=$key->getHash(); |
|
176 | 176 | |
177 | - if($value !== null) |
|
177 | + if($value!==null) |
|
178 | 178 | $this->_cache->set($key, $value, $this->_flushInterval); |
179 | 179 | } |
180 | 180 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | */ |
184 | 184 | public function getHitRatio() |
185 | 185 | { |
186 | - if($this->_requests != 0) |
|
186 | + if($this->_requests!=0) |
|
187 | 187 | return $this->_hits / $this->_requests; |
188 | 188 | else |
189 | 189 | return 0; |