Skip to content

Commit c1c9d65

Browse files
authored
Add "hidden" columns/fields into dbObject
1 parent 04cd1ab commit c1c9d65

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

dbObject.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ public function __construct ($data = null) {
124124
* @return mixed
125125
*/
126126
public function __set ($name, $value) {
127+
if ($name === 'hidden')
128+
return;
129+
130+
if (property_exists ($this, 'hidden') && array_search ($name, $this->hidden) !== false)
131+
return;
132+
127133
$this->data[$name] = $value;
128134
}
129135

@@ -135,8 +141,12 @@ public function __set ($name, $value) {
135141
* @return mixed
136142
*/
137143
public function __get ($name) {
144+
if ($name === 'hidden') /* Just in case... */
145+
return null;
146+
138147
if (isset ($this->data[$name]) && $this->data[$name] instanceof dbObject)
139-
return $this->data[$name];
148+
if (property_exists ($this, 'hidden') && array_search ($name, $this->hidden) === false)
149+
return $this->data[$name];
140150

141151
if (property_exists ($this, 'relations') && isset ($this->relations[$name])) {
142152
$relationType = strtolower ($this->relations[$name][0]);
@@ -159,9 +169,9 @@ public function __get ($name) {
159169
}
160170
}
161171

162-
if (isset ($this->data[$name])) {
163-
return $this->data[$name];
164-
}
172+
if (isset ($this->data[$name]))
173+
if (property_exists ($this, 'hidden') && array_search ($name, $this->hidden) === false)
174+
return $this->data[$name];
165175

166176
if (property_exists ($this->db, $name))
167177
return $this->db->$name;

0 commit comments

Comments
 (0)