From:             ethan dot charles at ltd dot org
Operating system: win 2k3 sql 2k5
PHP version:      5.2.6
PHP Bug Type:     PDO related
Bug description:  preparing SP execute command swaps params

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 bug report at http://bugs.php.net/?id=45128&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=45128&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=45128&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=45128&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=45128&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=45128&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=45128&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=45128&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=45128&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=45128&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=45128&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=45128&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=45128&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=45128&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=45128&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=45128&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=45128&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=45128&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=45128&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=45128&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=45128&r=mysqlcfg

Reply via email to