使用Show命令
SHOW TABLE STATUS;  or
mysqlshow --status TABLE;

解决方案 »

  1.   

    错了,应该用
    show full fields from '表名称'
      

  2.   

    function show_fields($sql)
    {
    $result=mysql_query($sql);
    $data=array();
    while ($row=mysql_fetch_array($result))
    {
    $data[]=$row['Field'];
    }
    return $data;
    }
      

  3.   

    调用:
    print_r(show_fields('show full fields from zy_article'));
      

  4.   

    //以下方法获得指定若干表的指定字段的comment 
       function get_all($SQL, $result_type = MYSQL_ASSOC) {
            $query = $this->query($SQL);
            while($row = mysql_fetch_array($query, $result_type)) $result[] = $row;
            return $result;
        }
        function table_comment($tables,$fields){
            if (is_array($tables)){
                $ts=$tables;
            }else{
                $ts[]=$tables;
            }
            
            foreach ($ts as $table){
                $results=$this->get_all("show full fields from $table");
                foreach($fields as $k=>$field){
                    foreach ($results as $key=>$result){
                        if ($field==$result['Field']){
                            $return[]=$result['Comment'];
                            unset($results[$key]);
                            unset($fields[$k]);
                            break;
                        }
                    }
                }
            }
            return $return;
        }调用方法
    echo "<pre>";
    print_r($db->table_comment(array("table1","table2"),array("name","id","name")));