Problem with returned from the database in class |
Hello. CodeIgniter 3.1.3 problem in the following
PHP Code: class User_lib { model PHP Code: public function get_customer() controller PHP Code: public function index() results PHP Code: D:\Ampps\www\igniter\application\controllers\Welcome.php:26: PHP Code: D:\Ampps\www\igniter\application\controllers\Welcome.php:30: Why are set value to non-public properties. In guide: The object will have all values returned from the database set as properties. If these have been declared and are non-public then you should provide a __set() method to allow them to be set. Sorry for my English
And use code tags.
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
You were asking why the object properties are not public.
Well, maybe because you declared them as protected in the User_lib class yourself? PHP Code: class User_lib { If properties are public, you can set them anywhere in your application like this: PHP Code: $this->User_lib->email = '[email protected]'; If properties are private or protected, you need a __set() method inside your object to change the value. Like this: PHP Code: public function __set($name, $value) This is a so-called magic method. It will be automatically called when you try to change the value of a non-public property.
The problem in the next, is not called __set method if set private or protected propeties.
Yet I have done so: PHP Code: class User_lib { And __set method now work
|
Welcome Guest, Not a member yet? Register Sign In |