Welcome Guest, Not a member yet? Register   Sign In
Problem with returned from the database in class
#1

(This post was last modified: 02-27-2017, 05:07 AM by phpforever2017.)

Hello. CodeIgniter 3.1.3 problem in the following


PHP Code:
class User_lib {
protected 
$customer_id;
protected 
$email;
protected 
$firstname;
protected 
$date_added;



model

PHP Code:
public function get_customer()
{
$this->db->from('stels_customer');
$this->db->where('stels_customer.customer_id'1);
$query $this->db->get();
return 
$query->row(0'User_lib');



controller

PHP Code:
public function index()
{
$this->load->model('user_model');
$this->load->library('user_lib');
var_dump($this->user_lib);
$user $this->user_model->get_customer();
var_dump($user);



results

PHP Code:
D:\Ampps\www\igniter\application\controllers\Welcome.php:26:
object(User_lib)[17]
protected 
'customer_id' => null
protected 'email' => null
protected 'firstname' => null
protected 'date_added' => null 



PHP Code:
D:\Ampps\www\igniter\application\controllers\Welcome.php:30:
object(User_lib)[20]
protected 
'customer_id' => string '1' (length=1)
protected 
'email' => string '[[email protected]][email protected][/email]' (length=16)
protected 
'firstname' => string 'Имя' (length=6)
protected 
'date_added' => string '2017-02-07 08:48:10' (length=19


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
Reply


Messages In This Thread
Problem with returned from the database in class - by phpforever2017 - 02-24-2017, 06:19 AM



Theme © iAndrew 2016 - Forum software by © MyBB