Welcome Guest, Not a member yet? Register   Sign In
Get last item in list
#1

Hi, In my database table I would like to be able to get the last row that was created.

Have I got this model function correct. Just unsure of my self not sure if there is another easier way?

PHP Code:
public function getpostinfofordeleteupdate()
{
 
   $query $this->db->order_by('datecreated''desc')
         
     ->limit(1)
         
     ->get($this->db->dbprefix 'posts');

 
   return $query->row_array();

Thanks for your time.
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Messages In This Thread
Get last item in list - by wolfgang1983 - 06-18-2017, 03:16 AM
RE: Get last item in list - by Martin7483 - 06-18-2017, 03:27 AM
RE: Get last item in list - by wolfgang1983 - 06-18-2017, 03:52 AM
RE: Get last item in list - by Martin7483 - 06-18-2017, 07:22 AM



Theme © iAndrew 2016 - Forum software by © MyBB