php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #28090 odbc_data_source does not return info about current connection.
Submitted: 2004-04-21 14:15 UTC Modified: 2004-09-16 15:42 UTC
From: richard dot quadling at carval dot co dot uk Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 4.3.6 OS: Windows XP Pro SP1
Private report: No CVE-ID: None
 [2004-04-21 14:15 UTC] richard dot quadling at carval dot co dot uk
Description:
------------
The documentation of odbc_data_source suggests that the information about the current connection will be used to provide the server and the description as part of the results.

This is NOT the case.

The function odbc_data_source returns information for all DSNs defined.

I am not sure if the bug is in the manual or the function.

The reason I say "suggest" is that you have to provide a connection.

Reproduce code:
---------------
From the example in the user notes.

<?php
// Example usage:

// Connect to a ODBC database that exists on your system
$link = odbc_connect("HRUnityOnline", "CARVAL_USER", "pswd") or die(odbc_errormsg() );

$result = @odbc_data_source( $link, SQL_FETCH_FIRST );
while($result)
{
   echo "DSN: " . $result['server'] . " - " . $result['description'] . "<br>\n";
   $result = @odbc_data_source( $link, SQL_FETCH_NEXT );
}

odbc_close($link); 
?>

Expected result:
----------------
DSN: HRUnityOnline - SQL Server

To acheive the desired result (i.e. you want to see the type of server type for the current DSN) ...

<?php
// Example usage:

$sDSN = "HRUnityOnline";
// Connect to a ODBC database that exists on your system
$link = odbc_connect($sDSN, "CARVAL_USER", "pswd") or die(odbc_errormsg() );

$result = @odbc_data_source( $link, SQL_FETCH_FIRST );
while($result)
{
if ($result['server'] == $sDSN)
	{
	echo "DSN: " . $result['server'] . " - " . $result['description'] . "<br>\n";
	break;
	}
$result = @odbc_data_source( $link, SQL_FETCH_NEXT );
}

odbc_close($link); 
?>

Actual result:
--------------
DSN: SageLine132 - Sage Line 100
DSN: SageLine50v10 - Sage Line 50 v10
DSN: Payroll32 - Microsoft Access Driver (*.mdb)
DSN: DBISAMTEST - DBISAM 3 ODBC Driver
DSN: HRUnityOnline - SQL Server
DSN: PCS - SQL Server
DSN: Bandvulc_PCS - SQL Server
DSN: Bandvulc CCC - Sage Line 100


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-09-16 15:42 UTC] vrana@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

Dup to bug #27249.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 04 13:01:30 2024 UTC