php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45128 preparing SP execute command swaps params
Submitted: 2008-05-29 18:12 UTC Modified: 2009-05-03 01:00 UTC
From: ethan dot charles at ltd dot org Assigned:
Status: No Feedback Package: PDO related
PHP Version: 5.2.6 OS: win 2k3 sql 2k5
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2008-05-29 18:12 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-25 15:03 UTC] jani@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2009-05-03 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 09 06:01:32 2024 UTC