Fetching MySQL results without a loop? |
[eluser]Been Told[/eluser]
Hi everyone, I'm a CI noob and I'm writing my first CI based script. I've run into a problem that seems stupid and so I thought I should take this opportunity to look stupid. The situation is this: I have written a query in a controller, like this: Code: $data['query2'] = $this->db->get_where('resources', array('id' => $this->uri->segment(3)),1); Code: $this->load->view('details_view',$data); Because the result() function page in the user guide here only features usage of result() inside loops - and I'm not sure how to "translate" that into just fetching one row. Without going through loops, as there will only be one result. I hope I'm making sense here... Anyway, help is greatly appreciated. I am running the latest CI (1.7.2) on XAMPP on Ubuntu, with PHP 5.2.
[eluser]danmontgomery[/eluser]
http://ellislab.com/codeigniter/user-gui...sults.html, 3rd heading down Code: $row = $query2->row();
[eluser]Been Told[/eluser]
[quote author="noctrum" date="1282322844"]http://ellislab.com/codeigniter/user-gui...sults.html, 3rd heading down Code: $row = $query2->row(); D'oh! Thanks! In the meantime I've figured to do this: Code: $result2 = $query2->result(); Code: $row = $query2->row(); Thanks! |
Welcome Guest, Not a member yet? Register Sign In |