@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | class Model { |
| 32 | 32 | |
| 33 | - /** |
|
| 33 | + /** |
|
| 34 | 34 | * This model's default database table. |
| 35 | 35 | * @var string the name of table |
| 36 | 36 | */ |
@@ -173,12 +173,12 @@ discard block |
||
| 173 | 173 | if ($db !== null) { |
| 174 | 174 | $this->setDb($db); |
| 175 | 175 | } else { |
| 176 | - /** |
|
| 177 | - * NOTE: Need use "clone" because some Model need have the personal instance of the database library |
|
| 178 | - * to prevent duplication |
|
| 179 | - */ |
|
| 180 | - $obj = & get_instance(); |
|
| 181 | - $this->setDb(clone $obj->database); |
|
| 176 | + /** |
|
| 177 | + * NOTE: Need use "clone" because some Model need have the personal instance of the database library |
|
| 178 | + * to prevent duplication |
|
| 179 | + */ |
|
| 180 | + $obj = & get_instance(); |
|
| 181 | + $this->setDb(clone $obj->database); |
|
| 182 | 182 | } |
| 183 | 183 | array_unshift($this->beforeCreateCallbacks, 'removeProtectedTableColumns'); |
| 184 | 184 | array_unshift($this->beforeUpdateCallbacks, 'removeProtectedTableColumns'); |
@@ -623,7 +623,7 @@ discard block |
||
| 623 | 623 | * Only get deleted rows on the next call |
| 624 | 624 | * |
| 625 | 625 | * @return object the current instance |
| 626 | - */ |
|
| 626 | + */ |
|
| 627 | 627 | public function onlyRecordDeleted() { |
| 628 | 628 | $this->returnOnlyRecordDeleted = true; |
| 629 | 629 | return $this; |
@@ -649,8 +649,8 @@ discard block |
||
| 649 | 649 | * @return array the data after add field for updated time |
| 650 | 650 | */ |
| 651 | 651 | public function updatedAt($row) { |
| 652 | - $row['updated_at'] = date('Y-m-d H:i:s'); |
|
| 653 | - return $row; |
|
| 652 | + $row['updated_at'] = date('Y-m-d H:i:s'); |
|
| 653 | + return $row; |
|
| 654 | 654 | } |
| 655 | 655 | |
| 656 | 656 | /** |
@@ -695,7 +695,7 @@ discard block |
||
| 695 | 695 | */ |
| 696 | 696 | public function removeProtectedTableColumns($row) { |
| 697 | 697 | foreach ($this->protectedTableColumns as $attr) { |
| 698 | - if (isset($row[$attr])) { |
|
| 698 | + if (isset($row[$attr])) { |
|
| 699 | 699 | unset($row[$attr]); |
| 700 | 700 | } |
| 701 | 701 | } |
@@ -818,23 +818,23 @@ discard block |
||
| 818 | 818 | return false; |
| 819 | 819 | } |
| 820 | 820 | |
| 821 | - /** |
|
| 822 | - * Get the record return type array or object |
|
| 823 | - * |
|
| 824 | - * @return string|boolean |
|
| 825 | - */ |
|
| 821 | + /** |
|
| 822 | + * Get the record return type array or object |
|
| 823 | + * |
|
| 824 | + * @return string|boolean |
|
| 825 | + */ |
|
| 826 | 826 | protected function getReturnType(){ |
| 827 | 827 | $type = false; |
| 828 | 828 | if ($this->temporaryReturnRecordType == 'array') { |
| 829 | - $type = 'array'; |
|
| 829 | + $type = 'array'; |
|
| 830 | 830 | } |
| 831 | 831 | return $type; |
| 832 | 832 | } |
| 833 | 833 | |
| 834 | - /** |
|
| 835 | - * Check if soft delete is enable setting the condition |
|
| 836 | - * @return object the current instance |
|
| 837 | - */ |
|
| 834 | + /** |
|
| 835 | + * Check if soft delete is enable setting the condition |
|
| 836 | + * @return object the current instance |
|
| 837 | + */ |
|
| 838 | 838 | protected function checkForSoftDelete(){ |
| 839 | 839 | if ($this->softDeleteStatus && $this->returnRecordWithDeleted !== true) { |
| 840 | 840 | $this->getQueryBuilder()->where( |
@@ -845,16 +845,16 @@ discard block |
||
| 845 | 845 | return $this; |
| 846 | 846 | } |
| 847 | 847 | |
| 848 | - /** |
|
| 849 | - * Relate for "manyToOne" and "oneToMany" |
|
| 850 | - * |
|
| 851 | - * @param string $relationship the name of relation |
|
| 852 | - * @param string|array $options the model and primary key values |
|
| 853 | - * @param object|array $row the row to update |
|
| 854 | - * @param string $type the type can be "manyToOne", "oneToMany" |
|
| 855 | - * |
|
| 856 | - * @return array|object the final row values |
|
| 857 | - */ |
|
| 848 | + /** |
|
| 849 | + * Relate for "manyToOne" and "oneToMany" |
|
| 850 | + * |
|
| 851 | + * @param string $relationship the name of relation |
|
| 852 | + * @param string|array $options the model and primary key values |
|
| 853 | + * @param object|array $row the row to update |
|
| 854 | + * @param string $type the type can be "manyToOne", "oneToMany" |
|
| 855 | + * |
|
| 856 | + * @return array|object the final row values |
|
| 857 | + */ |
|
| 858 | 858 | protected function relateOneToManyAndManyToOne($relationship, $options, $row, $type){ |
| 859 | 859 | if (in_array($relationship, $this->withs)) { |
| 860 | 860 | get_instance()->loader->model($options['model'], $relationship . '_model'); |