Welcome Guest, Not a member yet? Register   Sign In
getting the max id
#1

[eluser]Unknown[/eluser]
hi guys. i would like to get the max id, and then use that to determine the id of the record that i will be adding... here is the code that i came up with


Model :
Code:
$this->db->select_max('id');
   $query = $this->db->get('users');
   return $query->result();
Controller:
Code:
$this->load->model('crudModel');
   $maxId= $this->crudModel->maxid();
   $maxId2=$maxId++;

the problem with this code is that, whenever i try adding using the maxid2, an error occurs because according to it, my code is returning an array, how can I fix this? thank you very much for helping!




Theme © iAndrew 2016 - Forum software by © MyBB