php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55647 PDOStatement::execute() returns false when executing an UPDATE stored procedure
Submitted: 2011-09-08 18:38 UTC Modified: -
From: rcavicchioni at gmail dot com Assigned:
Status: Closed Package: PDO related
PHP Version: trunk-SVN-2011-09-08 (SVN) OS: CentOS 5.6 & 6
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: rcavicchioni at gmail dot com
New email:
PHP Version: OS:

 

 [2011-09-08 18:38 UTC] 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)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-06-01 07:40 UTC] ssufficool@php.net
Automatic comment on behalf of ssufficool
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c34a2757db80ee2a2f35583a73899330397cb35c
Log: FIX BUG #55647
 [2013-06-01 07:40 UTC] ssufficool@php.net
-Status: Open +Status: Closed
 [2013-06-04 03:40 UTC] ssufficool@php.net
Automatic comment on behalf of ssufficool
Revision: http://git.php.net/?p=php-src.git;a=commit;h=d8f938c78478c211dc3b5609e9f37d2e2c47896f
Log: FIX BUG #55647, #60512, #60512, #61900, #64338, #64808, #63638
 [2013-06-04 05:03 UTC] stas@php.net
Automatic comment on behalf of ssufficool
Revision: http://git.php.net/?p=php-src.git;a=commit;h=d8f938c78478c211dc3b5609e9f37d2e2c47896f
Log: FIX BUG #55647, #60512, #60512, #61900, #64338, #64808, #63638
 [2013-11-17 09:30 UTC] laruence@php.net
Automatic comment on behalf of ssufficool
Revision: http://git.php.net/?p=php-src.git;a=commit;h=d8f938c78478c211dc3b5609e9f37d2e2c47896f
Log: FIX BUG #55647, #60512, #60512, #61900, #64338, #64808, #63638
 [2013-11-17 09:31 UTC] laruence@php.net
Automatic comment on behalf of ssufficool
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c34a2757db80ee2a2f35583a73899330397cb35c
Log: FIX BUG #55647
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Oct 09 06:01:26 2024 UTC