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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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

Add a Patch

Pull Requests

Add a Pull Request

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: Tue Apr 30 07:01:28 2024 UTC