note 25274 added to function.mssql-query
| From: | jesse at lostangel dot net | Date: | Tue, 17 Sep 2002 20:33:59 +0000 |
| Subject: | note 25274 added to function.mssql-query | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-36854@lists.php.net to get a copy of this message | ||
While trying to return a @@IDENTITY after an INSERT statement, the only way I could get a valid
return result was to encapsulate the query within an EXEC like so:
$result = mssql_query("
exec(\"
INSERT INTO Files
(ownerId, name, sizeKB, path)
VALUES ('$contactId', '$userfile_name', '$filesize',
'$path')
SELECT @@IDENTITY as fileId\")
");
list($fileId) = mssql_fetch_row($result);
This returned the appropriate @@IDENTITY in a valid result set. Not sure if mssql supports multiple
inline commands or not. But that assumption would back the useage of the EXEC command in order to
execute these properly.
--
http://www.php.net/manual/en/function.mssql-query.php
http://master.php.net/manage/user-notes.php?action=edit+25274
http://master.php.net/manage/user-notes.php?action=delete+25274
http://master.php.net/manage/user-notes.php?action=reject+25274