0

I am executing the following sql code

$query = "INSERT INTO order_shipping_addresses(user_customer_id, shipping_address_details, created, modified) VALUES('".$_SESSION['user_id']."', '".serialize($address)."', '".$created."', '".$modified."')";
$connection = $this->establish_connection();
$data = $connection->query($query);
$order_shipping_address_id = last_insert_id();
$connection->close();

What i wanted was when this query is executed i wanted the row id in which this data is inserted, i am using the last_insert_id() function but i am getting an error of Call to undefined method mysqli::lastInsertId()

how to extract all the data from the $data variable and also the row id in which the data is inserted. I am using PHP OOP style.

Thanks in advance..

Akshay Shrivastav
  • 1,115
  • 4
  • 17
  • 43

1 Answers1

2

You want to use $connection->insert_id

segFault
  • 3,887
  • 1
  • 19
  • 31