]> git.mxchange.org Git - friendica.git/commitdiff
Add parameter for "toArray()" method
authornupplaPhil <admin@philipp.info>
Tue, 28 Jan 2020 00:33:29 +0000 (01:33 +0100)
committernupplaPhil <admin@philipp.info>
Tue, 28 Jan 2020 17:41:47 +0000 (18:41 +0100)
src/BaseModel.php
src/BaseRepository.php

index 791d6887c1702d088308bed27a4870b9c1766e0b..decc627521e50309a69dfe9195a1705ceab92b7d 100644 (file)
@@ -129,9 +129,16 @@ abstract class BaseModel
                $this->data[$name] = $value;
        }
 
-       public function toArray()
+       /**
+        * Returns the values of the current model as an array
+        *
+        * @param bool $dbOnly True, if just the db-relevant fields should be returned
+        *
+        * @return array The values of the current model
+        */
+       public function toArray(bool $dbOnly = false)
        {
-               return $this->mapFields($this->data);
+               return $dbOnly ? $this->mapFields($this->data) : $this->data;
        }
 
        protected function checkValid()
index cce1c50c17bc77f1cdc905a30297b8686f0c7b28..c14d6f7bc1283bbca258a8652ad28f7bcd36e5f0 100644 (file)
@@ -122,7 +122,7 @@ abstract class BaseRepository extends BaseFactory
         */
        public function update(BaseModel $model)
        {
-               if ($this->dba->update(static::$table_name, $model->toArray(), ['id' => $model->id], $model->getOriginalData())) {
+               if ($this->dba->update(static::$table_name, $model->toArray(true), ['id' => $model->id], $model->getOriginalData())) {
                        $model->resetOriginalData();
                        return true;
                }