downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

odbc_do> <odbc_cursor
[edit] Last updated: Fri, 17 May 2013

view this page in

odbc_data_source

(PHP 4 >= 4.3.0, PHP 5)

odbc_data_sourceBelirtilen bağlantı hakkında bilgi döndürür

Açıklama

array odbc_data_source ( resource $bağlantı_kimliği , int $alım_türü )

(Defalarca çağırdıktan sonra) Kullanılabilir DSN'lerin listesini döndürür.

Değiştirgeler

bağlantı_kimliği

ODBC bağlantı tanıtıcısı; ayrıntılar için odbc_connect() işlevine bakınız.

alım_türü

Şu iki sabitten biri olabilir: SQL_FETCH_FIRST ve SQL_FETCH_NEXT. İşlevi ilk çağırışınızda SQL_FETCH_FIRST, sonrakilerde SQL_FETCH_NEXT sabitini kullanın.

Dönen Değerler

Bir hata oluşmuşsa FALSE yoksa bir dizi döner.



add a note add a note User Contributed Notes odbc_data_source - [2 notes]
up
0
critmas at hotmail dot com
8 years ago
Thank you Angelo for point out the code.  Though the function doesn't really do what it is supposed to.  It returns the entire list of ODBC DSNs.
If you really are looking to get the server type based on just the ODBC, username and password in an environment where the application needs to be aware of different types of databases, use the following code:

$link2 = odbc_connect($dsn , $DBUser, $DBPwd ) or die(odbc_errormsg() );
$result = @odbc_data_source( $link2, SQL_FETCH_FIRST );
while($result)
{
    if (strtolower($dsn) == strtolower($result['server'])) {
        echo $result['description'] . "<br>\n";
        break;
    }
       else
        $result = @odbc_data_source( $link2, SQL_FETCH_NEXT );
}

odbc_close($link2);

// Hope it saves your precious time
up
0
angelo [at] spaceblue [dot] com
9 years ago
// Example usage:

// Connect to a ODBC database that exists on your system
$link = odbc_connect("some_dsn_name", "user", "password") 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);

 
show source | credits | stats | sitemap | contact | advertising | mirror sites