(PECL CUBRID >= 8.3.0)
cubrid_insert_id — Returns an array with the IDs generated for the AUTO_INCREMENT columns
This function returns an array with the IDs generated for the AUTO_INCREMENT columns that were updated by the previous INSERT query. It returns an array with all the AUTO_INCREMENT columns and their values. It returns 0 if the previous query does not generate new rows, or it returns FALSE on failure.
The name of the class (table) that was used in the last INSERT statement for which the auto increment values are retrieved.
The connection identifier previously obtained by a call to cubrid_connect().
An associative array with all the AUTO_INCREMENT columns and their values, on success.
0, if the previous query does not generate new rows.
FALSE on failure.
Example #1 cubrid_insert_id() example
<?php
$link = cubrid_connect("localhost", 30000, "demodb2", "dba", "");
if (!$link)
{
die('Could not connect.');
}
$query = "insert into employees (name, address, salary) values ('Michael', 'Boston, MA', 3750)";
$result = cubrid_execute($link, $query);
if ($result)
{
$array_id = cubrid_insert_id("employees");
echo "Last insert id was ".$array_id["id"];
cubrid_close_request($result);
}
?>
The above example will output:
Result: Last insert id was 10