odbc_tables

(PHP 4, PHP 5, PHP 7, PHP 8)

odbc_tables — Belli bir veri kaynağında bulunan tablo isimlerini döndĂŒrĂŒr

Açıklama

function odbc_tables(
    resource $odbc,
    ?string $katalog = null,
    ?string $Ɵema = null,
    ?string $tablo = null,
    ?string $tĂŒrler = null
): resource|false

Belitilen aralıktaki tĂŒm tablo isimlerini listeler.

katalog, ßema, tablo ve tĂŒrler bağımsız değißkenleri ile seçim ĆŸĂ¶yle yapılır:

  • katalog tek bir yĂŒzde iminden (%) ibaretse ve, ßema ve tablo birer boß dizgeyse sonuç, veri kaynağındaki geçerli niteleyicileri içerir. (TABLE_QUALIFIER sĂŒtunu dıßında tĂŒm sĂŒtunlar null içerir.)
  • ßema tek bir yĂŒzde iminden (%) ibaretse ve, katalog ve tablo birer boß dizgeyse sonuç, veri kaynağındaki geçerli sahipleri içerir. (TABLE_OWNER sĂŒtunu dıßında tĂŒm sĂŒtunlar null içerir.)
  • tablo_tĂŒrĂŒ tek bir yĂŒzde iminden (%) ibaretse ve, katalog, ßema ve tablo birer boß dizgeyse sonuç, veri kaynağındaki geçerli tablo tĂŒrlerini içerir. (TABLE_TYPE sĂŒtunu dıßında tĂŒm sĂŒtunlar null içerir.)

Bağımsız Değißkenler

odbc

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

katalog

Katalog (ODBC 2 argosunda 'qualifier' ).

ßema

ƞema (ODBC 2 argosunda 'owner'). Arama ßablonları belirtilebilir (sıfır veya daha fazla karakterle eßleßmek ĂŒzere "%" ve tek bir karakterle eßleßmek ĂŒzere "_".

tablo

İsim. Arama ßablonları belirtilebilir (sıfır veya daha fazla karakterle eßleßmek ĂŒzere "%" ve tek bir karakterle eßleßmek ĂŒzere "_".

tĂŒrler

tĂŒrler boß bir dizge değilse tablo tĂŒrlerinden olußan virgĂŒl ayraçlı bir liste olmalıdır. Her değer ya tek tırnaklar (') arasına alınmalı ya da hiç tırnak içine alınmamalıdır. Örnek: 'TABLE','VIEW' veya TABLE, VIEW. Eğer veri kaynağı belirtilen tablo tĂŒrlerini desteklemiyorsa, ißlev, bu tablo tĂŒrlerinde hiçbir sonuç döndĂŒrmez.

Dönen Değerler

İstenen bilgiyi içeren bir ODBC sonuç tanıtıcısı, baßarısızlık durumunda false döner.

Sonuç kĂŒmesi ßu sĂŒtunlardan olußur:

  • TABLE_CAT
  • TABLE_SCHEM
  • TABLE_NAME
  • TABLE_TYPE
  • REMARKS
Drivers can report additional columns.

Sonuç kĂŒmesi TABLE_TYPE, TABLE_CAT, TABLE_SCHEM ve TABLE_NAME sĂŒtunlarına göre sıralanır.

SĂŒrĂŒm Bilgisi

SĂŒrĂŒm: Açıklama
8.0.0 ßema, tablo ve tĂŒrler artık null olabiliyor.

Örnekler

Örnek 1 - Katalogdaki tabloların listesi

<?php
$conn
= odbc_connect($dsn, $user, $pass);
$tables = odbc_tables($conn, 'SalesOrders', 'dbo', '%', 'TABLE');
while ((
$row = odbc_fetch_array($tables))) {
print_r($row);
break;
}
?>

Yukarıdaki örnek ßuna benzer bir çıktı ĂŒretir:

Array
(
    [TABLE_CAT] => SalesOrders
    [TABLE_SCHEM] => dbo
    [TABLE_NAME] => Orders
    [TABLE_TYPE] => TABLE
    [REMARKS] =>
)

Ayrıca Bakınız

add a note

User Contributed Notes 3 notes

up
2
liquidicee at hotmail dot com ¶
25 years ago
Here's how to get a list of all the tables in your database.. with an actual example of how its done and how to get the results.. and you don't need to put in schema and all that other crap

<?php
$conn = odbc_connect("$database", "$username", "$password");
$tablelist = odbc_tables($conn);
while (odbc_fetch_row($tablelist)) {
if (odbc_result($tablelist, 4) == "TABLE")
echo odbc_result($tablelist, 3) ."<br>";
}
?>

to understand what the above is doing,
use odbc_result_all($tablelist); this will show you EVERYTHING returned by odbc_tables() then you can look through it and see better how odbc_tables() works and what exactly it returns in the string to get a better idea on how to deal with it.
it would have saved me alot of time if i would have just taken a look at the full string returned by odbc_tables(), so i suggest you take the minute or two and look... here is an example of how to do it..which would have been helpful for me ;x.

<?php
$conn = odbc_connect("$database", "$username", "$password");
$tablelist = odbc_tables($conn);
while (odbc_fetch_row($tablelist)) {
echo odbc_result_all($tablelist);
}
?>

hopefully this will help some people.. i have alot more to add about this but no time :(
so again hope this helps.
Liquidice
up
0
narcomweb at wanadoo dot fr ¶
20 years ago
Here a Code for listing Table names
<?php
$dbh = odbc_connect($dsn, $user, $pwd);

   $result = odbc_tables($dbh);

   $tables = array();
   while (odbc_fetch_row($result)){
     if(odbc_result($result,"TABLE_TYPE")=="TABLE")
       echo"<br>".odbc_result($result,"TABLE_NAME");

   }
?>
You don't have views or System tables with.
Only simple tables in your database.
up
0
iggvopvantoodlwin ¶
22 years ago
With regard to the note made on results not working.
Test the database with the easy:

odbc_result_all(odbc_tables($db));

$db is obviously a connected batadase. Then start to experiment:

if(!$odbcr=odbc_tables($db,"udb","", "%", "'TABLE'"))

"udb" is the DNS - aka 'name of my ODBC database in the Windows ODBC thingamy'. In result_all the full path was shown but I just used the name I assigned; either should work.

The second parameter "" is listed by result_all as "TABLE_SCHEM" and all items were "NULL", so I have put "".

The third parameter is "%". According to result_all this col is "TABLE_NAME", so I could have put the name of one of my tables, i.e. "Address".

In my case I have an Access database setup with several tables. In ODBC I have created a link. Running the all on everything result above shows a set of system tables which I do not need to know about at this point so I look at the result and then build my new table check using the "TABLE" string as the tables I am interested in are listed as "TABLE" under their "TABLE_TYPE" column.