note 23080 added to function.mssql-init
| From: | shrockc at NOinhs dot orgSPAM | Date: | Tue, 09 Jul 2002 01:19:30 +0000 |
| Subject: | note 23080 added to function.mssql-init | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-32777@lists.php.net to get a copy of this message | ||
If you are performing a stored procedure inside a loop, it is a good idea to unset the variable that
mssql_init returns so that you do NOT bind multiple values to the same stored procedure:
foreach($input as $sid=>$value) {
$stmt = mssql_init("sp_doSomething");
mssql_bind($stmt, "@sid", $sid, SQLINT4, false);
mssql_bind($stmt, "@value", $value, SQLINT4, false);
$result = mssql_execute($stmt);
unset($stmt); // <---VERY important
}
Even doing the mssql_init outside the loop does not help because of the multiple binds happening
inside the loop.
Failing to do the above generates "Access Violations...memory cannot be
'written'" errors on the server. My hypothesis is that the error is generated when
you try to bind to a stored procedure after it has already been executed. You have been warned.
--
http://www.php.net/manual/en/function.mssql-init.php
http://master.php.net/manage/user-notes.php?action=edit+23080
http://master.php.net/manage/user-notes.php?action=delete+23080
http://master.php.net/manage/user-notes.php?action=reject+23080