cubrid_insert_id

(PECL CUBRID >= 8.3.0)

cubrid_insert_idReturns an array with the IDs generated for the AUTO_INCREMENT columns

Description

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.

Parameters

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().

Return Values

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.

Examples

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

Copyright © 2010-2024 Platon Technologies, s.r.o.           Home | Man pages | tLDP | Documents | Utilities | About
Design by styleshout