php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #62761 Returns an ODBC connection id or 0 (FALSE) on error. Which is it?
Submitted: 2012-08-06 19:57 UTC Modified: 2012-11-16 14:13 UTC
From: mmellon at ecrs dot com Assigned: krakjoe (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: Windows
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: mmellon at ecrs dot com
New email:
PHP Version: OS:

 

 [2012-08-06 19:57 UTC] mmellon at ecrs dot com
Description:
------------
---
From manual page: http://www.php.net/function.odbc-connect#refsect1-
function.odbc-connect-returnvalues
---

"Returns an ODBC connection id or 0 (FALSE) on error."

Out of habit, I usually code with the following sort of conditional construct

if (false !== ($foo = bar()))
{
   echo 'Houston we have a problem';
}
else
{
   echo 'bar() was good';
}

The documentation is not good enough for this function to test equality with 
type equivalence. The function odbc_connect does not actually return FALSE. It 
returns 0 or a connection id.

The documentation should state "Returns an ODBC connection id if successful, or 
returns 0 on error."


Test script:
---------------
<?php

// requires ODBC support
$db = odbc_connect('this','should','fail');
print_r($db);

?>

Expected result:
----------------
According to the documentation, it could spit out FALSE.

Actual result:
--------------
It always spits out 0.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-11-16 14:09 UTC] krakjoe@php.net
Automatic comment from SVN on behalf of krakjoe
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=328382
Log: bug #62761
 [2012-11-16 14:13 UTC] krakjoe@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

The function returns false on failure, additionally, you should use var_dump to 
inspect the internal type and content of data.
 [2012-11-16 14:13 UTC] krakjoe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: krakjoe
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 00:00:02 2026 UTC