我正在编写一个脚本来根据主数据库检查客户的数据库是否是最新的,但是
$this -> db-> field_data($a_table)
函数不返回所有字段详细信息。
我需要详细信息,例如 AUTO INCREMENT(在 PhpMyAdmin 的 Extra 下)、ASSIGNED ZEROFILL(在 Attributes 下)以及所有其他信息,例如 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;
关于mysql - Codeigniter 获取所有字段信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39289374/