Issue
How to display the database table names list in CodeIgniter using given syntax:
$tables=$this->db->query("SHOW TABLES LIKE '%Demo%'");
Solution
You have to specify the database name
.
Check this,
SHOW TABLES FROM `database-name` LIKE '%a%'
See mysql documentation here
To get table names,
$tables=$this->db->query("SELECT t.TABLE_NAME AS myTables FROM INFORMATION_SCHEMA.TABLES AS t WHERE t.TABLE_SCHEMA = 'database name' AND t.TABLE_NAME LIKE '%a%' ")->result_array();
foreach($tables as $key => $val) {
echo $val['myTables']."<br>";// myTables is the alias used in query.
}
Answered By - Niranjan N Raju
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.