![]() |
php basics query on data passed to model - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: php basics query on data passed to model (/showthread.php?tid=55619) |
php basics query on data passed to model - El Forum - 11-03-2012 [eluser]deepakaggarwal[/eluser] In my controller, I've: Code: ... In my view, I access result as: Code: $result->car_color; All good! But I'm curious to know 2 things (I'm new to PHP altogether... Hence the curiosity) ![]() 1. How does a variable added as an array ($result) gets accessible in view in an object oriented way? Just want to get hint on how this happens in PHP. 2. if I do a var_dump($this) on my view, I do see my passed data as: Code: ["_ci_cached_vars":protected]=> array(1) { ["result"]=> object(stdClass)#17 (2) { ["car_color"]=> string(5) "green" ["car-make"]=> string(4) "1990" } } $this->result->car_color $this->result['car_color] and many more. I want to know when result is within $this, then how to access result using $this-> notation. thanks. php basics query on data passed to model - El Forum - 11-03-2012 [eluser]deepakaggarwal[/eluser] **MISTAKENLY ADDED IN NO CODE FORUM SECTION** Moderator, please shift my query to appropriate section! thanks php basics query on data passed to model - El Forum - 11-04-2012 [eluser]Aken[/eluser] The $data array passed in $this->load->view() goes through extract(), to create variables based on the array keys. In the view, you would use $result, not using $this. |