![]() |
Why 2 successive $data = $this->model->func(); statements overlap? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Why 2 successive $data = $this->model->func(); statements overlap? (/showthread.php?tid=8579) |
Why 2 successive $data = $this->model->func(); statements overlap? - El Forum - 05-23-2008 [eluser]EthanSP[/eluser] Why do the $data values on the first $data = $this->model->func() call cannot be retrieved on my view file? I highlighted (in red) the variable ($base) that won't show up its value: Controller: function demographics() { $this->load->helper('form'); $this->load->helper('html'); $this->load->model('bangungot_model'); if($this->input->post('mysubmit')) { $this->bangungot_model->add_entry(); } $data = $this->bangungot_model->get_paths(); $data = $this->bangungot_model->get_fields(); $this->load->view('demographics', $data); } Model: function get_paths() { $data['base'] = $this->config->item('base_url'); $data['custom_css'] = $this->config->item('custom_css'); $data['banner'] = $data['base'].'index.php/welcome/banner'; return $data; } function get_fields() { $data['title'] = 'Demographics'; $data['fid'] = array('name'=>'id'); $data['ffn'] = array('name'=>'fname'); return $data; } View: ... <link href="<?= "$base/$custom_css" ?>" rel="stylesheet" type="text/css"> ... <div class="jwin1"> <?= heading($title,3); echo form_open('books/input'); ?> </div> ... <div class="jmenu"> <ul class="jdatacol"> <!-- style="width:200px;" --> <?= "<li>".form_input($fid)."</li>"; ... ?> <li><label><input type="radio" name="Sex" value="female" style="width: 12px;" /> Female</label> ... </ul> </div> <div class="jwin3"> <? //<input name="save" type="button" value="Save changes" class="jbutton" /></div> echo form_submit('mysubmit','Submit!'); echo form_close(); ?> </div> ... Why 2 successive $data = $this->model->func(); statements overlap? - El Forum - 05-23-2008 [eluser]xwero[/eluser] You are overwriting one array with the other. You have to do Code: $data = array_merge($this->bangungot_model->get_paths(),$this->bangungot_model->get_fields()); Why 2 successive $data = $this->model->func(); statements overlap? - El Forum - 05-23-2008 [eluser]EthanSP[/eluser] [quote author="xwero" date="1211548359"]You are overwriting one array with the other. You have to do Code: $data = array_merge($this->bangungot_model->get_paths(),$this->bangungot_model->get_fields()); Wow, it worked! You're a genius, xwero!!! Thank you very much for your time & for sharing a piece of your mind. Cheers to the CI community! Why 2 successive $data = $this->model->func(); statements overlap? - El Forum - 05-23-2008 [eluser]xwero[/eluser] That wasn't genius that was basic programming knowledge. |