PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Database » DB » Bug #4452

Return of query function

Details

Submitted2005-05-27 13:50 UTC
Frommarkus dot espenlaub at espas dot ch
Assigneddanielc
StatusNo Feedback
PackageDB
PHP Version5.0.3
OSWindows 2000
Roadmaps(Not assigned)

Comments

[2005-05-27 13:50 UTC] markus dot espenlaub at espas dot ch

Description:
------------
I use DB 1.7.6 and MSDE (Microsoft SQL Server) 2000 SP3.

When I *successfully* create a table using query() then the function returns always a DB_Error object with error code 0. I don't know if other DBMS behave different or give another result code on success.

According to the documentation the correct result should be DB_OK. I also think that the maintainer team don't expect the developers to read error codes manually to determine success or failure.

Reproduce code:
---------------
<?php
require_once 'DB.php';

$db =& DB::connect('pgsql://usr:pw@localhost/dbnam');
if (PEAR::isError($db)) {
die($db->getMessage());
}

$res =& $db->query('create table example (
ID_Example int identity constraint st_pk primary key,
ID_Location int,
Date datetime constraint st_c1 not null);');

// Always check that result is not an error
if (PEAR::isError($res)) {
// Dies always in release 1.7.6 when using MSDE 2000
die($res->getMessage());
}
?>

Expected result:
----------------
$db->query() returns DB_OK on success

Actual result:
--------------
$db->query() returns a DB_Error object

$res::getCode() returns 0

[2005-05-27 15:03 UTC] markus dot espenlaub at espas dot ch

Seems to be a bug in Microsoft SQL Server 2000 (returns bogus error code on successful data definition commands).

[2005-11-17 22:40 UTC] markus dot espenlaub at espas dot ch

Workaround: My code now considers error 0 (unknown error) as no error. I did find no better solution and had no other msde installations for testing.