From e2c9c2a873f9c73808c119f3b30970d2abff9f59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Nowacki?= Date: Mon, 3 Sep 2018 11:54:12 +0200 Subject: [PATCH] Update Model.php adding additional if for __get method to make easier achieve sth like this: $row->{$model->primaryKey} --- system/Model.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/system/Model.php b/system/Model.php index b9baeec5e3d3..4a8b9ce49727 100644 --- a/system/Model.php +++ b/system/Model.php @@ -1376,7 +1376,7 @@ protected function trigger(string $event, array $data) //-------------------------------------------------------------------- /** - * Provides/instantiates the builder/db connection. + * Provides/instantiates the builder/db connection and model's table/primary key names and return type. * * @param string $name * @@ -1384,7 +1384,11 @@ protected function trigger(string $event, array $data) */ public function __get(string $name) { - if (isset($this->db->$name)) + if(in_array($name, ['primaryKey', 'table', 'returnType'])) + { + return $this->{$name}; + } + elseif (isset($this->db->$name)) { return $this->db->$name; }