CUBRID 函数
PHP Manual

cubrid_insert_id

(PECL CUBRID >= 8.3.0)

cubrid_insert_idReturns an array with the IDs generated for the AUTO_INCREMENT columns

说明

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

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.

参数

class_name

The name of the class (table) that was used in the last INSERT statement for which the auto increment values are retrieved.

conn_identifier

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); 
    }
?>

以上例程会输出:

Result:
Last insert id was 10

CUBRID 函数
PHP Manual