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 Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
22 + 33 = ?
Subscribe to this entry?

 
 [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 03:01:31 2024 UTC