Edit report at https://bugs.php.net/bug.php?id=55647&edit=1

 ID:                 55647
 Updated by:         ssuffic...@php.net
 Reported by:        rcavicchioni at gmail dot com
 Summary:            PDOStatement::execute() returns false when executing
                     an UPDATE stored procedure
-Status:             Open
+Status:             Closed
 Type:               Bug
 Package:            PDO related
 Operating System:   CentOS 5.6 & 6
 PHP Version:        trunk-SVN-2011-09-08 (SVN)
 Block user comment: N
 Private report:     N

 New Comment:

Automatic comment on behalf of ssufficool
Revision: 
http://git.php.net/?p=php-src.git;a=commit;h=c34a2757db80ee2a2f35583a73899330397cb35c
Log: FIX BUG #55647


Previous Comments:
------------------------------------------------------------------------
[2011-09-08 18:38:34] rcavicchioni at gmail dot com

Description:
------------
When using PDO dblib, PDOStatement::execute() is returning false with a stored 
procedure that only contains an UPDATE statement. The procedure actually 
succeeds and modifies the data as expected.

I discovered this issue because we upgraded to PHP 5.3.8 from 5.3.6 using the 
RPMs from the Remi repository. I looked at the RPM spec file and this patch is 
being applied for PHP bug #50755: 
https://raw.github.com/remicollet/remirepo/master/php/php-5.3.7-pdo-dblib-50755.patch

According to the comments in the spec file, the patch is based off the 
following commits:

http://svn.php.net/viewvc?view=revision&revision=300002
http://svn.php.net/viewvc?view=revision&revision=300089
http://svn.php.net/viewvc?view=revision&revision=300646
http://svn.php.net/viewvc?view=revision&revision=300791

Before reporting a bug to the Remi repository, I decided that I would try to 
duplicate the bug in PHP-trunk and I was able to.

Our environment:

MSSQL 2008
FreeTDS 0.82 (from the EPEL repo)
PHP-trunk
CentOS 5.6

Here is a simple example of the type of stored procedure that we are using.

CREATE PROCEDURE [dbo].[TestProc]
    @iID integer,
    @sFoo varchar(max)
AS
BEGIN
    UPDATE TestTable
    SET foo = @sFoo 
    WHERE id = @iID;
END

The stored procedure does not return any results, yet is executed successfully. 
PDOStatement::execute() returns false, but it returns true in vanilla PHP 
5.3.8. It seems that since the procedure does not return any results, it causes 
PDOStatement::execute() to return false not true.


Test script:
---------------
<?php
$db = new PDO($dsn, $username, $password);

$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$sql = 'EXEC TestProc ?, ?';
$stmt = $db->prepare($sql);
$id = 123;
$foo = 'Hello ...';
$stmt->bindParam(1, $id, PDO::PARAM_INT);
$stmt->bindParam(2, $foo, PDO::PARAM_STR);
$ret = $stmt->execute();

var_dump($ret);
?>

Expected result:
----------------
bool(true)

Actual result:
--------------
bool(false)


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=55647&edit=1

Reply via email to