Re: pdo::lastInsertId() error with SQL Server

From: Date: Thu, 29 Mar 2007 18:10:48 +0000
Subject: Re: pdo::lastInsertId() error with SQL Server
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-251655@lists.php.net to get a copy of this message
use scope_identity() if you're using MS SQL Server 2000 or newer. scope_identity slects the last id within your current scope (The last record you entered in your current session) On 3/29/07, Sady Marcos <smarcos@digidata.com.br> wrote:
hey.. I am not obtaining use the function pdo::lastInsertId() with sql My code: $db = new PDO("mssql:host=host;dbname=database","user","password"); $sql = "INSERT INTO users(name,status) VALUES('username','1)"; $db->query($sql); $db->lastInsertId(); Error: SQLSTATE[IM001]: Driver does not support this function: driver does not support lastInsertId() This is true? The only way would be executing query "SELECT @@IDENTITY as Id" ? Thanks for help -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.general (#251655) next »