Làm thế nào bạn có thể xem cấu trúc của một bảng trong php?

Actually, the initially posted SELECT COUNT[*] approach is flawless. SELECT COUNT[*] will provide one and only one row in response unless you can't select from the table at all. Even a brand new [empty] table responds with one row to tell you there are 0 records.

While other approaches here are certainly functional, the major problem comes up when you want to do something like check a database to ensure that all the tables you need exist, as I needed to do earlier today. I wrote a function called tables_needed[] that would take an array of table names -- $check -- and return either an array of tables that did not exist, or FALSE if they were all there. With mysql_list_tables[], I came up with this in the central block of code [after validating parameters, opening a connection, selecting a database, and doing what most people would call far too much error checking]:

if[$result=mysql_list_tables[$dbase,$conn]]
{   // $count is the number of tables in the database
    $count=mysql_num_rows[$result];
    for[$x=0;$x

Chủ Đề