今天在做东西时候 遇到一个问题:“如何得到mysql数据表中自动增长字段的索引基数。”
费尽周折 终于得到方法了:
$query = $this->db->query('SHOW INDEX from tree;');
//查询语句是 show index from tree。
//请注意,我这里使用ci的数据库类库。自己测试的请自行写好查询语句。
$row = $query->row();
print_r($row);//打印结果
这样我会得到
stdClass Object
(
[Table] => tree //表名
[Non_unique] => 0
[Key_name] => PRIMARY
[Seq_in_index] => 1
[Column_name] => tid
[Collation] => A
[Cardinality] => 6 //索引基数6,要得就是它!
[Sub_part] =>
[Packed] =>
[Null] =>
[Index_type] => BTREE
[Comment] =>
)