Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Versions available for this page: CUBRID 8.3.0 |  CUBRID 8.3.1 |  CUBRID 8.4.0 |  CUBRID 8.4.1 | 



The cubrid_insert_id function retrieves the ID generated for the AUTO_INCREMENT columns which is updated by the previous INSERT query and returns every AUTO_INCREMENT column and its value in array. If the value of AUTO_INCREMENT is not generated in the previous query, 0 is returned; if CUBRID connection fails, FALSE is returned.

Note If more than one AUTO_INCREMENT column in a single table exists, you sholuld not use this function.


array cubrid_insert_id (string $class_name [, resource $conn_identifier])

  • class_name : The name of the class (table) that was used in the last INSERT statement for which the auto increment values are retrieved.
  • connection_identifier : Connection identifier previously obtained from a call to cubrid_connect()
Return Value
  • Success : Associative array that has every AUTO_INCREMENT column and its value
  • If the previous query does not generate a new row : 0
  • Failure : FALSE


$conn = cubrid_connect("localhost", 33000, "demodb");


@cubrid_execute($conn, "DROP TABLE cubrid_test");

cubrid_execute($conn, "CREATE TABLE cubrid_test (d int AUTO_INCREMENT(1, 2), t varchar)");


for ($i = 0; $i < 10; $i++) {

    cubrid_execute($conn, "INSERT INTO cubrid_test(t) VALUES('cubrid_test')");



$id_list = cubrid_insert_id("cubrid_test");






The above example will output:


array(1) {