You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
echo "showing $page out of " . product::$totalPages;
296
296
297
297
```
298
+
299
+
###Hidden Fields
300
+
Sometimes it's important to block some fields that can be accessed from outside the model class (for example, the user password).
301
+
302
+
To block the access to certain fields using the `->` operator, you can declare the `$hidden` array into the model class. This array holds column names that can't be accessed with the `->` operator.
303
+
304
+
For example:
305
+
306
+
```php
307
+
class User extends dbObject {
308
+
protected $dbFields = array(
309
+
'username' => array('text', 'required'),
310
+
'password' => array('text', 'required'),
311
+
'is_admin' => array('bool'),
312
+
'token' => array('text')
313
+
);
314
+
315
+
protected $hidden = array(
316
+
'password', 'token'
317
+
);
318
+
}
319
+
```
320
+
321
+
If you try to:
322
+
```php
323
+
echo $user->password;
324
+
echo $user->token;
325
+
```
326
+
327
+
Will return `null`, and also:
328
+
```php
329
+
$user->password = "my-new-password";
330
+
```
331
+
332
+
Won't change the current `password` value.
333
+
298
334
###Examples
299
335
300
336
Please look for a use examples in <ahref='tests/dbObjectTests.php'>tests file</a> and test models inside the <ahref='tests/models/'>test models</a> directory
0 commit comments