php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #27249 odbc_data_source returns avaible DNS, not information about argument
Submitted: 2004-02-14 00:18 UTC Modified: 2004-09-16 15:39 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: jlsalinas at gmx dot net Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.3.4 OS: Windows Me
Private report: No CVE-ID: None
 [2004-02-14 00:18 UTC] jlsalinas at gmx dot net
Description:
------------
Even though the documentation states that odbc_data_source "Returns information about a current connection", it returns the list of avaible DNS (after calling it several times).

This is a good feature, but maybe in a function called odbc_list_dns and without the need for an argument with a previously established connection (maybe ODBC internals require the connection to get them, I don't know).

What I expected after reading the docs about odbc_data_source was:
 - odbc driver used (xtg for interbase6 in my case)
 - underlying database (firebird 1.5rc8 in my case)
 - perhaps other information, depending on the dbms

My code is:

----- begin --------------------------
<pre>
<?php
  $conn = odbc_connect ($dns_name, $user, $pass);
  if ($ds = @odbc_data_source ($conn, SQL_FETCH_FIRST)) {
    do {
      var_dump ($ds);
    } while ($ds = @odbc_data_source ($conn, SQL_FETCH_NEXT));
  }
?>
</pre>
----- end ----------------------------

The result (I'm from Spain):

----- begin --------------------------
array(2) {
  ["server"]=>
  string(23) "Archivos de texto ASCII"
  ["description"]=>
  string(36) "Microsoft Text Driver (*.txt; *.csv)"
}
array(2) {
  ["server"]=>
  string(18) "MS Access Database"
  ["description"]=>
  string(31) "Microsoft Access Driver (*.mdb)"
}
[...and some more]
----- end ----------------------------

You see? First, if this function is supposed to give information about the connection and its data source, why do I need to call it many times? It's not gonna change! Moreover, the information it gives the first time, with SQL_FETCH_FIRST, does not correspond with the specified connection.

And, what is the need to specify if it's the first time or not (SQL_FETCH_FIRST and SQL_FETCH_NEXT constants)? This second argument makes no sense to me. Even in a odbc_list_dns function, I'd prefer the function to return all the DNS as an array, and not having to call it several times, inside a somewhat weird loop.

I think that correct function calls should be:
 - odbc_data_source ($conn)
 - odbc_list_dns ()

Again, I don't know the internals of ODBC. Maybe odbc_list_dns *needs* a connection to work. Ok. But, please, no different arguments for the first and the following calls.

Thank you very much. Keep on doing doing such a great job!



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-19 01:31 UTC] kalowsky@php.net
The documentation may be out of whack, but your request 
to remove the SQL_FETCH_FIRST and SQL_FETCH_NEXT calls 
is denied.  Unfortunately, the SQL call underneath 
requires these to be passed in.

As for the connection issue, unfortunately due to the 
nature of the ODBC system, an environment variable must 
be passed to the call.  The only place the environment 
variable exists is within a connection.
 [2004-09-16 15:39 UTC] vrana@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.

"This function will return the list of avaible DNS (after calling it several times)."

If you want other functionality, create bug in Category "Feature request".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 12:01:32 2024 UTC