我正在编写一个脚本,以根据主数据库检查客户端的数据库是否最新,但是

$this -> db-> field_data($a_table)


函数不会返回所有字段详细信息。

我需要详细信息,例如AUTO INCREMENT(在PhpMyAdmin中的Extra中),ASSIGNED ZEROFILL(在属性下)以及所有其他信息,例如auto_increment的起始位置

我找不到任何其他方式来获取这些信息,因此,如果不可能,那就很好,但是如果有人知道如何获取这些信息,那将是很好的。

提前感谢

最佳答案

使用以下方式

$this->db->list_fields('table')


要么

$fields = $this->db->field_data('table-name');

foreach ($fields as $field)
{
   echo $field->name;        // name
   echo $field->type;        // type
   echo $field->max_length;  // maxlength
   echo $field->primary_key; // primary key
}


和自动增量

$next = $this->db->query("SHOW TABLE STATUS LIKE 'table-name'");
$next = $next->row(0);
$next->Auto_increment;
echo $next->Auto_increment;

10-07 19:10
查看更多