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, 06 Nov 2009

view this page in

mysql_tablename

(PHP 4, PHP 5)

mysql_tablenameRetorna o nome da tabela do campo

Descrição

string mysql_tablename ( resource $result , int $i )

mysql_tablename() usa um ponteiro de resultado retornado por mysql_list_tables() ou um índice inteiro e retorna o nome da tabela A função mysql_num_rows() pode ser usada para determinar o número de tabelas no ponteiro do resultado. Use a função mysql_tablename() para transpor o resultado, ou qualquer função para pegar o resultado como mysql_fetch_array().

Exemplo #1 Exemplo mysql_tablename()

<?php
mysql_connect
("localhost""mysql_user""mysql_password");
$result mysql_list_tables("mydb");

for (
$i 0$i mysql_num_rows($result); $i++) {
    echo 
"Table: "mysql_tablename($result$i), "\n";
}

mysql_free_result($result);
?>

Veja também mysql_list_tables().



add a note add a note User Contributed Notes
mysql_tablename
Haseldow
23-Apr-2004 10: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 02: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, 06 Nov 2009
 
 
show source | credits | sitemap | contact | advertising | mirror sites