PHP Doku:: Returns an array with the IDs generated for the AUTO_INCREMENT columns - function.cubrid-insert-id.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzDatenbankerweiterungenAnbieterspezifische DatenbankerweiterungenCubridCubrid Funktionencubrid_insert_id

Ein Service von Reinhard Neidl - Webprogrammierung.

Cubrid Funktionen

<<cubrid_get

cubrid_is_instance>>

cubrid_insert_id

(PECL CUBRID >= 8.3.0)

cubrid_insert_idReturns an array with the IDs generated for the AUTO_INCREMENT columns

Beschreibung

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.

Parameter-Liste

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

Rückgabewerte

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.

Beispiele

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

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

Result:
Last insert id was 10

Keine BenutzerBeiträge.
- Beiträge aktualisieren...



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)