1. 程式人生 > >ci 判斷表是否存在,如不存在則建立表

ci 判斷表是否存在,如不存在則建立表

$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')
}

}