@@ -51,24 +51,24 @@ |
||
| 51 | 51 | return $records; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Uses ContextClass and ContextID to get an object. |
|
| 56 | - * Quick way to attach things to other objects in a one-to-one relationship |
|
| 57 | - * |
|
| 58 | - * @param array $record An array of database rows. |
|
| 59 | - * @return ActiveRecord|null An array of instantiated ActiveRecord models from the provided data. |
|
| 60 | - */ |
|
| 54 | + /** |
|
| 55 | + * Uses ContextClass and ContextID to get an object. |
|
| 56 | + * Quick way to attach things to other objects in a one-to-one relationship |
|
| 57 | + * |
|
| 58 | + * @param array $record An array of database rows. |
|
| 59 | + * @return ActiveRecord|null An array of instantiated ActiveRecord models from the provided data. |
|
| 60 | + */ |
|
| 61 | 61 | public static function getByContextObject(ActiveRecord $Record, $options = []) |
| 62 | 62 | { |
| 63 | 63 | return static::getByContext($Record::$rootClass, $Record->getPrimaryKeyValue(), $options); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | - * Same as getByContextObject but this method lets you specify the ContextClass manually. |
|
| 68 | - * |
|
| 69 | - * @param array $record An array of database rows. |
|
| 70 | - * @return ActiveRecord|null An array of instantiated ActiveRecord models from the provided data. |
|
| 71 | - */ |
|
| 67 | + * Same as getByContextObject but this method lets you specify the ContextClass manually. |
|
| 68 | + * |
|
| 69 | + * @param array $record An array of database rows. |
|
| 70 | + * @return ActiveRecord|null An array of instantiated ActiveRecord models from the provided data. |
|
| 71 | + */ |
|
| 72 | 72 | public static function getByContext($contextClass, $contextID, $options = []) |
| 73 | 73 | { |
| 74 | 74 | if (!static::fieldExists('ContextClass')) { |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | return DB::oneRecord( |
| 186 | 186 | (new Select())->setTable(static::$tableName)->where(join(') AND (', $conditions))->order($order ? join(',', $order) : '')->limit('1'), |
| 187 | 187 | null, |
| 188 | - [static::class,'handleException'] |
|
| 188 | + [static::class, 'handleException'] |
|
| 189 | 189 | ); |
| 190 | 190 | } |
| 191 | 191 | |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | */ |
| 199 | 199 | public static function getByQuery($query, $params = []) |
| 200 | 200 | { |
| 201 | - return static::instantiateRecord(DB::oneRecord($query, $params, [static::class,'handleException'])); |
|
| 201 | + return static::instantiateRecord(DB::oneRecord($query, $params, [static::class, 'handleException'])); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
@@ -309,9 +309,9 @@ discard block |
||
| 309 | 309 | $select->limit(sprintf('%u,%u', $options['offset'], $options['limit'])); |
| 310 | 310 | } |
| 311 | 311 | if ($options['indexField']) { |
| 312 | - return DB::table(static::_cn($options['indexField']), $select, null, null, [static::class,'handleException']); |
|
| 312 | + return DB::table(static::_cn($options['indexField']), $select, null, null, [static::class, 'handleException']); |
|
| 313 | 313 | } else { |
| 314 | - return DB::allRecords($select, null, [static::class,'handleException']); |
|
| 314 | + return DB::allRecords($select, null, [static::class, 'handleException']); |
|
| 315 | 315 | } |
| 316 | 316 | } |
| 317 | 317 | |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | */ |
| 325 | 325 | public static function getAllByQuery($query, $params = []) |
| 326 | 326 | { |
| 327 | - return static::instantiateRecords(DB::allRecords($query, $params, [static::class,'handleException'])); |
|
| 327 | + return static::instantiateRecords(DB::allRecords($query, $params, [static::class, 'handleException'])); |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | /** |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | */ |
| 338 | 338 | public static function getTableByQuery($keyField, $query, $params = []) |
| 339 | 339 | { |
| 340 | - return static::instantiateRecords(DB::table($keyField, $query, $params, [static::class,'handleException'])); |
|
| 340 | + return static::instantiateRecords(DB::table($keyField, $query, $params, [static::class, 'handleException'])); |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | /** |
@@ -395,9 +395,9 @@ discard block |
||
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | if ($options['indexField']) { |
| 398 | - return DB::table(static::_cn($options['indexField']), $select, null, null, [static::class,'handleException']); |
|
| 398 | + return DB::table(static::_cn($options['indexField']), $select, null, null, [static::class, 'handleException']); |
|
| 399 | 399 | } else { |
| 400 | - return DB::allRecords($select, null, [static::class,'handleException']); |
|
| 400 | + return DB::allRecords($select, null, [static::class, 'handleException']); |
|
| 401 | 401 | } |
| 402 | 402 | } |
| 403 | 403 | |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | return ', '.$value.' AS '.$key; |
| 468 | 468 | } |
| 469 | 469 | } else { |
| 470 | - return ', ' . $columns; |
|
| 470 | + return ', '.$columns; |
|
| 471 | 471 | } |
| 472 | 472 | } |
| 473 | 473 | } |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | public static function buildHaving($having) |
| 482 | 482 | { |
| 483 | 483 | if (!empty($having)) { |
| 484 | - return ' (' . (is_array($having) ? join(') AND (', static::_mapConditions($having)) : $having) . ')'; |
|
| 484 | + return ' ('.(is_array($having) ? join(') AND (', static::_mapConditions($having)) : $having).')'; |
|
| 485 | 485 | } |
| 486 | 486 | } |
| 487 | 487 | } |