> >
> > To insert the record I use this code:
> > $sSql = "INSERT INTO myTable (time_in ) VALUES ( getdate() )";
>
> try something like
> $sSql = "INSERT INTO myTable (time_in ) VALUES ( getdate() ); SELECT
> @@IDENTITY";
>
> works with the Perl DBI at least.
>
> :-)christian
>

But if I get the ID in a second queries on a very busy web server with less
persistant database connection, it is not reliable. If two clients execute
this call at the same time with the same connection, I would possiblely get
the wrong ID, wouldn't I? Is there a way to do this in one step?

By the way, I can't use a string with more than one query in the
mssql_query() function. I get error like:
Attempt to initiate a new SQL Server operation with results pending
on the next query() call.

Heiko

"Heiko Mundle" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I insert a new record with PHP into my MS SQL Server database.
> The key is defined with
>     auto_id                        INT         IDENTITY(1000,1) NOT NULL,
>
> how do I get the new id to use it in PHP?
>
> To insert the record I use this code:
> $sSql = "INSERT INTO myTable (time_in ) VALUES ( getdate() )";
> $pResult = mssql_query($sSql, $g_pDBServer);
>
>
> Thanks a lot for your help
>
> Heiko
>
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to