#45128 [Opn->Fbk]: preparing SP execute command swaps params
| From: | jani@php.net | Date: | Sat, 25 Apr 2009 15:03:22 +0000 |
| Subject: | #45128 [Opn->Fbk]: preparing SP execute command swaps params | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-136282@lists.php.net to get a copy of this message | ||
ID: 45128
Updated by: jani@php.net
Reported By: ethan dot charles at ltd dot org
-Status: Open
+Status: Feedback
Bug Type: PDO related
Operating System: win 2k3 sql 2k5
PHP Version: 5.2.6
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows:
http://windows.php.net/snapshots/
Previous Comments:
------------------------------------------------------------------------
[2008-05-29 18:12:06] ethan dot charles at ltd dot org
Description:
------------
The order of parameters in a stored procedure must be strictly followed
in PDO, otherwise, the parameters will get swapped around in the trace.
Reproduce code:
---------------
CREATE a stored procedure in SQL with two parameters in order:
@param1 nvarchar(100),
@param2 nvarchar(100)
Run a trace in profiler to watch what PDO prepares and executes against
the server.
Prepare the EXEC statement but swap the order of the parameters.
If you prepare and execute a query in the form:
$statement = connection->prepare(
"EXEC dbo.sptest @param2=:param2,@param1=:param1"
);
$statement->execute(array(':param1' => 'test1', ':param2' =>
'test2'));
Expected result:
----------------
I would expect that the stored procedure will be prepared by PDO in the
form:
declare @p1 int
set @p1=NULL
exec sp_prepare @p1 output,N'@test1 nvarchar(100),@test2
nvarchar(100)',N'EXECUTE runtest @test2 = @test2, @test1 = @test1',1
select @p1
Actual result:
--------------
I would expect that the stored procedure will be prepared by PDO in the
form:
declare @p1 int
set @p1=NULL
exec sp_prepare @p1 output,N'@test1 nvarchar(100),@test2
nvarchar(100)',N'EXECUTE runtest @test2 = @test1, @test1 = @test2',1
select @p1
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=45128&edit=1