Get all table names in yii Get all table names in yii database database

Get all table names in yii


try this one:

$connection = Yii::app()->db;//get connection$dbSchema = $connection->schema;//or $connection->getSchema();$tables = $dbSchema->getTables();//returns array of tbl schema'sforeach($tables as $tbl){    echo $tbl->rawName, ':<br/>', implode(', ', $tbl->columnNames), '<br/>';}

Refer:How to get all table and column names from database in Yii Framework


If you want to use yii then Mani`s answer is correct. If you want to get table names using create Command then you can use

$sql='SELECT * FROM INFORMATION_SCHEMA.TABLES'$tables = Yii::app()->db         ->createCommand($sql)         ->queryAll();


The simple is simple:

var_dump(Yii::app()->db->schema->getTableNames();

http://www.yiiframework.com/doc/api/1.1/CDbSchema - here look for detail