Table of Contents
valentina_insert_id()
Declaration
long valentina_insert_id ( [resource link_identifier], [string dbName] )
Parameters
Name | Description |
---|---|
link_identifier | The VServer connection. If the link identifier is not specified, the last link opened by valentina_connect() is assumed. If by chance no connection is found, an E_WARNING level warning is generated. |
dbName | If dbName is specified then returns the last RecID for the specified database. |
Description
Retrieves the RecID of the last inserted query.
Return Values
The RecID value generated by the previous INSERT query on success, or FALSE in case of any error (for example - no connection established).
Examples
Example 1.
<?php $link = valentina_connect('localhost', 'val_user', 'val_password'); if (!$link) { die('Could not connect: ' . valentina_error()); } valentina_select_db('mydb'); valentina_query("INSERT INTO mytable (product) values ('php')"); printf("Last inserted record has id %d\n", valentina_insert_id()); ?>
Notes
Note: Because valentina_insert_id() acts on the last performed query, you should understand that it could be the query issued by another client or even scheduled event.