@@ -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'); |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | * Only get deleted rows on the next call |
593 | 593 | * |
594 | 594 | * @return object the current instance |
595 | - */ |
|
595 | + */ |
|
596 | 596 | public function onlyRecordDeleted() { |
597 | 597 | $this->returnOnlyRecordDeleted = true; |
598 | 598 | return $this; |
@@ -686,8 +686,8 @@ discard block |
||
686 | 686 | * @return array the data after add field for updated time |
687 | 687 | */ |
688 | 688 | protected function updatedAt($row) { |
689 | - $row['updated_at'] = date('Y-m-d H:i:s'); |
|
690 | - return $row; |
|
689 | + $row['updated_at'] = date('Y-m-d H:i:s'); |
|
690 | + return $row; |
|
691 | 691 | } |
692 | 692 | |
693 | 693 | /** |
@@ -732,7 +732,7 @@ discard block |
||
732 | 732 | */ |
733 | 733 | protected function removeProtectedTableColumns($row) { |
734 | 734 | foreach ($this->protectedTableColumns as $attr) { |
735 | - if (isset($row[$attr])) { |
|
735 | + if (isset($row[$attr])) { |
|
736 | 736 | unset($row[$attr]); |
737 | 737 | } |
738 | 738 | } |
@@ -787,23 +787,23 @@ discard block |
||
787 | 787 | return false; |
788 | 788 | } |
789 | 789 | |
790 | - /** |
|
791 | - * Get the record return type array or object |
|
792 | - * |
|
793 | - * @return string|boolean |
|
794 | - */ |
|
790 | + /** |
|
791 | + * Get the record return type array or object |
|
792 | + * |
|
793 | + * @return string|boolean |
|
794 | + */ |
|
795 | 795 | protected function getReturnType(){ |
796 | 796 | $type = false; |
797 | 797 | if ($this->temporaryReturnRecordType == 'array') { |
798 | - $type = 'array'; |
|
798 | + $type = 'array'; |
|
799 | 799 | } |
800 | 800 | return $type; |
801 | 801 | } |
802 | 802 | |
803 | - /** |
|
804 | - * Check if soft delete is enable setting the condition |
|
805 | - * @return object the current instance |
|
806 | - */ |
|
803 | + /** |
|
804 | + * Check if soft delete is enable setting the condition |
|
805 | + * @return object the current instance |
|
806 | + */ |
|
807 | 807 | protected function checkForSoftDelete(){ |
808 | 808 | if ($this->softDeleteStatus && $this->returnRecordWithDeleted !== true) { |
809 | 809 | $this->getQueryBuilder()->where( |
@@ -814,16 +814,16 @@ discard block |
||
814 | 814 | return $this; |
815 | 815 | } |
816 | 816 | |
817 | - /** |
|
818 | - * Relate for "manyToOne" and "oneToMany" |
|
819 | - * |
|
820 | - * @param string $relationship the name of relation |
|
821 | - * @param string|array $options the model and primary key values |
|
822 | - * @param object|array $row the row to update |
|
823 | - * @param string $type the type can be "manyToOne", "oneToMany" |
|
824 | - * |
|
825 | - * @return array|object the final row values |
|
826 | - */ |
|
817 | + /** |
|
818 | + * Relate for "manyToOne" and "oneToMany" |
|
819 | + * |
|
820 | + * @param string $relationship the name of relation |
|
821 | + * @param string|array $options the model and primary key values |
|
822 | + * @param object|array $row the row to update |
|
823 | + * @param string $type the type can be "manyToOne", "oneToMany" |
|
824 | + * |
|
825 | + * @return array|object the final row values |
|
826 | + */ |
|
827 | 827 | protected function relateOneToManyAndManyToOne($relationship, $options, $row, $type){ |
828 | 828 | if (in_array($relationship, $this->withs)) { |
829 | 829 | get_instance()->loader->model($options['model'], $relationship . '_model'); |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | $keysList = array(); |
411 | 411 | foreach ($keys as $k => $v) { |
412 | 412 | $v = $this->checkForNullValue($v); |
413 | - if (! is_numeric($v)) { |
|
413 | + if (!is_numeric($v)) { |
|
414 | 414 | $v = $this->connection->escape($v, $escape); |
415 | 415 | } |
416 | 416 | $keysList[] = $v; |
@@ -721,7 +721,7 @@ discard block |
||
721 | 721 | * |
722 | 722 | * @return string|null |
723 | 723 | */ |
724 | - protected function buildQueryPart($property, $command = ''){ |
|
724 | + protected function buildQueryPart($property, $command = '') { |
|
725 | 725 | if (!empty($this->{$property})) { |
726 | 726 | return $command . $this->{$property}; |
727 | 727 | } |
@@ -736,7 +736,7 @@ discard block |
||
736 | 736 | * @param string $clause the clause type "IS NULL", "IS NOT NULLs" |
737 | 737 | * @return object the current DatabaseQueryBuilder instance |
738 | 738 | */ |
739 | - protected function whereIsNullAndNotNull($field, $andOr = 'AND', $clause = 'IS NULL'){ |
|
739 | + protected function whereIsNullAndNotNull($field, $andOr = 'AND', $clause = 'IS NULL') { |
|
740 | 740 | if (is_array($field)) { |
741 | 741 | foreach ($field as $f) { |
742 | 742 | $this->whereIsNullAndNotNull($f, $andOr, $clause); |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | * |
755 | 755 | * @return object the current instance |
756 | 756 | */ |
757 | - protected function setSelectStr($newSelect){ |
|
757 | + protected function setSelectStr($newSelect) { |
|
758 | 758 | $this->select = (($this->select == '*' || empty($this->select)) |
759 | 759 | ? $newSelect |
760 | 760 | : $this->select . ', ' . $newSelect); |
@@ -768,8 +768,8 @@ discard block |
||
768 | 768 | * @return string the empty string if the value is null |
769 | 769 | * otherwise the same value will be returned |
770 | 770 | */ |
771 | - protected function checkForNullValue($value){ |
|
772 | - if(is_null($value)){ |
|
771 | + protected function checkForNullValue($value) { |
|
772 | + if (is_null($value)) { |
|
773 | 773 | return ''; |
774 | 774 | } |
775 | 775 | return $value; |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | * |
797 | 797 | * @return string |
798 | 798 | */ |
799 | - protected function getWhereStrForOperator($where, $op = null, $value= null, $type = '', $escape = true) { |
|
799 | + protected function getWhereStrForOperator($where, $op = null, $value = null, $type = '', $escape = true) { |
|
800 | 800 | $w = ''; |
801 | 801 | if (!in_array((string) $op, $this->operatorList)) { |
802 | 802 | $op = $this->checkForNullValue($op); |