ci 判断表是否存在,如不存在则创建表

来源:互联网 发布:淘宝顶呱呱代练lol 编辑:程序博客网 时间:2024/05/17 23:02

$table = 'ed_table1'

if(!$this->db->table_exists($table)){

$sql = "CREATE TABLE IF NOT EXISTS $table LIKE ed_table";
if (! $res = $this->db->query($sql)) {
throw new exception('create_table_failure')
}

}

阅读全文
1 0