Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [MySQL] czy istnieje tabela
-Guest-
post 30.09.2004, 10:21:56
Post #1





Goście







W jaki sposob mozna sprawdzic czy w bazie jest tabela o zadanej nazwie.

Nie chodzi mi o fizyczne sprawdzenie np. w phpMyAdmin, tylko bezposrednie kodzie php.
Go to the top of the page
+Quote Post
jol.us_
post 30.09.2004, 10:52:29
Post #2





Grupa: Zarejestrowani
Postów: 132
Pomógł: 0
Dołączył: 10.12.2003
Skąd: Kraków

Ostrzeżenie: (0%)
-----


Rodem z manuala.

  1. <?php
  2. A simple function to check for the existance of a table:
  3.  
  4. function TableExists($tablename, $db) {
  5.  
  6.  // Get a list of tables contained within the database.
  7.  $result = mysql_list_tables($db);
  8.  $rcount = mysql_num_rows($result);
  9.  
  10.  // Check each in list for a match.
  11.  for ($i=0;$i<$rcount;$i++) {
  12.  if (mysql_tablename($result, $i)==$tablename) return true;
  13.  }
  14.  return false;
  15. } 
  16. ?>


--------------------
run Forest run ...
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 28.04.2024 - 03:52