Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.
int sqlanywhere_identity( resource link_identifier )
int sqlanywhere_insert_id( resource link_identifier )
不建议使用此函数。应该改用以下 PHP 函数: sasql_insert_id.
返回最后插入到 IDENTITY 列或 DEFAULT AUTOINCREMENT 列中的值,如果是最后插入到了不含 IDENTITY 或 DEFAULT AUTOINCREMENT 列的表中,则返回零。
提供 sqlanywhere_insert_id 函数是为了与 MySQL 数据库兼容。
link_identifier sqlanywhere_connect 或 sqlanywhere_pconnect 返回的链接标识符。
由前一个 INSERT 语句为 AUTOINCREMENT 列生成的 ID,如果最后的插入对 AUTOINCREMENT 列没有影响,则返回零。如果 link_identifier 无效,则该函数会返回 FALSE。
本示例说明如何能够使用 sqlanywhere_identity 函数检索由指定连接最新插入到表中的自动增量值。
if( sqlanywhere_execute( $conn, "INSERT INTO my_auto_increment_table VALUES ( 1 ) " ) ) { $insert_id = sqlanywhere_insert_id( $conn ); echo "Last insert id = $insert_id"; }