I have a query like this:
<?php
$this->db->query("INSERT INTO customer SET email = '" . $this->db->escape($data['email']) . "'");
?>
And after this i need to make an INSERT to another table like this:
$this->db->query("INSERT INTO order SET customer_id = '" . //here goes the id i need from previous query ."'";
In my customer table i have only one auto-increment column called customer_id and after first insertion to this table i need to get this customer_id value and use it to the next insertion (to order table).
How can i do this? I read about
$mysqli->insert_id
but all the examples connect to a database whereas i am already connected to database and run queries with this->db. Any help about syntax or other solution is really appreciated!