2017-02-21 82 views
-4
$this->db->query("show tables");  
$tables = $this->db->get();  
return $tables->result_array(); 

错误编号:1096个
无表使用
SELECT *我想表现出笨从我的数据库表

+0

**许多优秀的问题都会根据专家的经验产生一定程度的意见,但对这个问题的回答往往基于意见,而不是事实,参考或具体专业知识。** –

+0

'$ this- > db-> list_tables()'使用这个查询来列出你的数据库表 –

+0

http://stackoverflow.com/questions/34151291/how-to-display-the-database-table-names-list-in- codeigniter –

回答

1

使用$this->db->list_tables()获得从数据库中所有表的名称。

$tables = $this->db->list_tables(); 

foreach ($tables as $table) 
{ 
     echo $table; 
} 

更多请见文档Codeigniter Metadata

+0

好的得到了感谢... – hasnain

+0

@hasnain乐于帮助。快乐的编码。 –

+0

最好不要添加重复的答案,Bcz有这个确切的副本http://stackoverflow.com/questions/34151291/how-to-display-the-database-table-names-list-in-codeigniter –

1

$this->db->get()Query Builder方法,并且你不使用QB来创建查询。

你应该在query()返回值直接调用result_array(),像这样:

$result = $this->db->query("SHOW TABLES"); 
$tables = $result->result_array(); 

如果你看过documentation这是显而易见的。你可以使用list_tables()