-1

Blockquote

how to return last inserted id , if the booking id is variable character in codeigniter**

strong text

**

sels
  • 1
  • 2

1 Answers1

0

If you are using codeigniter 3 use this:

$this->db->insert_id();

If you are using codeigniter 4 use this:

$this->db->insertID();

all this should be within you model or where you called the database connect. I hope this help you else call my attentions okay?

Chibueze Agwu
  • 910
  • 5
  • 12
  • actually iam using $this->db->insert_id(); this methode, but my bookind id was varraiable character so the last inserted id always shows 0 – sels Jan 29 '20 at 06:36
  • Do you mean you store the $this->db->insert_id() into a variable like `$id = $this->db->insert_id();` . if this is what you do please return the value of the id to get the value you are looking for. Example `function insertbooking () { // your query command here return id = $this->db->insert_id();}` the call it anywhere like this ` echo insert booking()`. I hope this will help you else call my attention – Chibueze Agwu Feb 03 '20 at 16:20