2013-07-22 34 views

回答

1

如果你想檢查表,然後執行這個查詢

$query = $this->db->query("SHOW TABLES LIKE mytable_name"); 

它將成果,這是與名稱mytable_name,如果它一點兒也不存在任何表,則它會導致空表。

或者乾脆你可以嘗試像

if ($this->db->table_exists('mytable_name')) { 
    echo 'Table is already exists'; 
} else { 
    CREATE table 
} 
+1

我想他的意思[這](http://dev.mysql.com/doc/refman/5.0/en /exists-and-not-exists-subqueries.html)...? –

0

有沒有這樣的條款「不存在」的活動記錄。但是,你可以通過你的「不存在條款」這樣的where子句中:

$this->db->where('NOT EXISTS ');