![]() |
How can i get single value without foreach - 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: How can i get single value without foreach (/showthread.php?tid=9873) |
How can i get single value without foreach - El Forum - 07-10-2008 [eluser]Zeeshan Rasool[/eluser] Hi guys, here im trying to fetch single value from db is there any method that get single value without foreach Code: foreach ($query as $item){ thnx in adv. How can i get single value without foreach - El Forum - 07-11-2008 [eluser]Doosje[/eluser] Code: $row = $query->row(); How can i get single value without foreach - El Forum - 07-11-2008 [eluser]sophistry[/eluser] a refinement on Doosje's suggestion (which is good) is to also use the LIMIT parameter in your query. check the db docs, i think it is the second param you can send with a $this->db->get() method. that way you only get one record. How can i get single value without foreach - El Forum - 07-11-2008 [eluser]onejaguar[/eluser] I created a helper function to do this for me: Code: // just call with Code: echo db_pop($query); |