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

search for in the

mysql_thread_id> <mysql_stat
Last updated: Fri, 13 Nov 2009

view this page in

mysql_tablename

(PHP 4, PHP 5)

mysql_tablenameAlanın tablo adını al

Açıklama

string mysql_tablename ( resource $sonuç , int $i )

Bir sonuç 'tan tablo adını alır.

Bu işlevin kullanımı önerilmemektedir. Bunun yerine, SHOW TABLES [FROM db_adı] [LIKE 'şablon'] şeklinde bir SQL ifadesi çalıştırmak için mysql_query() kullanılması tercih edilebilir.

Değiştirgeler

sonuç

mysql_list_tables() işlevinden döndürülen resource türünde bir sonuç göstericisi.

i

Tamsayı indisi (satır/tablo numarası)

Dönen Değerler

Başarı durumunda tablo adı, hata durumunda FALSE döndürülür.

Bu sonuç göstericisini veya mysql_fetch_array() gibi sonuç tabloları üreten bir işlevden elde edilen işlevselliğin tersini elde etmek için mysql_tablename() işlevini kullanın.

Örnekler

Örnek 1 - mysql_tablename() örneği

<?php
mysql_connect
("localhost""mysql_user""mysql_password");
$result mysql_list_tables("mydb");
$num_rows mysql_num_rows($result);
for (
$i 0$i $num_rows$i++) {
    echo 
"Tablo: "mysql_tablename($result$i), "\n";
}

mysql_free_result($result);
?>

Notlar

Bilginize: mysql_num_rows() işlevi sonuç göstericisindeki tablo sayısını belirlemek için kullanılabilir.

Ayrıca Bakınız



add a note add a note User Contributed Notes
mysql_tablename
Haseldow
23-Apr-2004 12:00
Another way to check if a table exists:

if(mysql_num_rows(mysql_query("SHOW TABLES LIKE '".$table."'"))==1) echo "Table exists";
else echo "Table does not exist";
pl at thinkmetrics dot com
17-Dec-2003 04:00
A simple function to check for the existance of a table:

function TableExists($tablename, $db) {
   
    // Get a list of tables contained within the database.
    $result = mysql_list_tables($db);
    $rcount = mysql_num_rows($result);

    // Check each in list for a match.
    for ($i=0;$i<$rcount;$i++) {
        if (mysql_tablename($result, $i)==$tablename) return true;
    }
    return false;
}

mysql_thread_id> <mysql_stat
Last updated: Fri, 13 Nov 2009
 
 
show source | credits | sitemap | contact | advertising | mirror sites