Welcome Guest, Not a member yet? Register   Sign In
data passed to view - using objects rather then arrays
#2

[eluser]fesweb[/eluser]
You can use a standard object like this:
Code:
$data = new stdClass();
$data->title = 'My Title';
$data->heading = 'My Heading';
$data->message = 'My Message';

$this->load->view(‘blogview’, $data);
You can also, of course, use database result objects as well.
Code:
$this->db->where('id', $id);
$q = $this->db->get('blog_items');
$data = $q->result():
// or even add more data to the object first
$data->my_other_info = 'other info'
$this->load->view('blogview', $data);


Messages In This Thread
data passed to view - using objects rather then arrays - by El Forum - 07-30-2011, 01:52 PM
data passed to view - using objects rather then arrays - by El Forum - 07-30-2011, 10:27 PM



Theme © iAndrew 2016 - Forum software by © MyBB