How to display the database table names list in CodeIgniter using given syntax:
$tables=$this->db->query("SHOW TABLES LIKE '%Demo%'");
How to display the database table names list in CodeIgniter using given syntax:
$tables=$this->db->query("SHOW TABLES LIKE '%Demo%'");
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.
}
You can use this:
$tables = $this->db->list_tables();
foreach ($tables as $table)
{
echo $table;
}
documentation
Try with information_schema.tables
Example:
$query = $this->db->query("SELECT * FROM information_schema.tables WHERE **** ");
$result = $query->result_array();
return $result;
Go through this Chapter 19 INFORMATION_SCHEMA
Tables
EDIT 01
$this->db->list_tables();
$this->db->like('name', 'field');