CodeIgniter Forums
Need help returning single row from database - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Need help returning single row from database (/showthread.php?tid=42656)

Pages: 1 2


Need help returning single row from database - El Forum - 06-14-2011

[eluser]blinger2008[/eluser]
i thought that's what it was, i will try that. thanks


Need help returning single row from database - El Forum - 06-14-2011

[eluser]blinger2008[/eluser]
when i load the view without the print_r, it says no records returned. but i am passing the $person variable

Code:
function person(){
        $data = array();
        
        if($this->uri->segment(3)) {
        $person=$this->people_model->get_record($this->uri->segment(3));

        $this->load->view('content/person', $person);
        //print_r($person);
        //die();
        } else {
        if($query = $this->people_model->get_record()){
            $data['records'] = $query;
            }
    }
        
        
        }



Need help returning single row from database - El Forum - 06-14-2011

[eluser]JHackamack[/eluser]
because $person is a row and a single array. where in your view you're looking for an array of multiple arrays. You can change $person = $this to $data['records'] = $this and in the get_record change the ->row() to ->result()


Need help returning single row from database - El Forum - 06-14-2011

[eluser]blinger2008[/eluser]
that worked. thank you so much!