I have a question I have a table of users with two fields id which is already the primary key and auto increment however I have another field that is called user_id which is separate that I'll need to have auto increment but the first row inserted will have a value of 10000 in the db and increment after that.
Here's my function so far for creating a user in the database. How can I with as less code as possible have it insert the first row as 10000 and then add 1 after that.
/**
* Create new user record
*
* @param array
* @param bool
* @return array
*/
function create_user($data)
{
$data['created'] = date('Y-m-d H:i:s');
$this->db->set('username', $data['username']);
$this->db->set('password', $data['password']);
$this->db->set('password2', $data['password2']);
$this->db->set('email', $data['email']);
$this->db->set('first_name', $data['first_name']);
$this->db->set('last_name', $data['last_name']);
$query = $this->db->insert('users');
if ($query)
{
$user_id = $this->db->insert_id();
if ($activated) $this->create_profile($user_id);
return array('user_id' => $user_id);
}
return NULL;
}