php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36662 PDO_ODBC->MSSQL: exec() returns false when doing "DELETE" on nonexisting row
Submitted: 2006-03-09 08:02 UTC Modified: 2006-04-09 08:41 UTC
From: gustav at cst dot co dot za Assigned:
Status: Not a bug Package: PDO related
PHP Version: 5.1.2 OS: Microsoft Windows XP
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: gustav at cst dot co dot za
New email:
PHP Version: OS:

 

 [2006-03-09 08:02 UTC] gustav at cst dot co dot za
Description:
------------
Hi,

I use PDO_ODBC (linked against Win32 ODBC) to connect to MSSQL. Webserver is IIS 5.

When I run a "DELETE" statement that tries to delete a nonexisting row, exec() returned FALSE instead of int(0).

An existing row deletes fine.


Reproduce code:
---------------
<?php
    $dsn = 'odbc:database';
    $user = 'user';
    $password = 'pass';

    $dbh = new PDO($dsn, $user, $password);

    $result = 
    $dbh->exec("DELETE FROM radio WHERE station_id = 10");

    if ($result===false)
      echo "FALSE";
    else
      $result;
?>    

Expected result:
----------------
0

Actual result:
--------------
FALSE

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-09 11:44 UTC] gustav at cst dot co dot za
The problem seems more general than I realised. an UPDATE affecting 0 rows *also* returns FALSE instead of int(0).

This following error message is returned in both cases:
SQLExecDirect[0] at ext\pdo_odbc\odbc_driver.c:230

NOTE: A temporary workaround is to use query() instead of exec().
 [2006-04-09 08:41 UTC] wez@php.net
Duplicate of #36632.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 05 12:01:29 2024 UTC