I m using PHP ActiveRecord in my application
How to list all the table names of the database
Here i had configured the connection of database as below
require_once ActiveRecordDIR.'/ActiveRecord.php';
ActiveRecord\Config::initialize(function($cfg){
$cfg->set_model_directory('core/models');
$cfg->set_connections(array('development' =>'mysql://root:pass@localhost/dbname'));
});
After this i wanna list out all the table names in database "dbname"
An Active Record represents a single row in single table and adds business logic to it, so pattern-wise there should be no way to query all the tables in the database from an ActiveRecord because there is no use-case for that in the pattern.
However, according to that framework's docs you can use
Connection::query()
- Execute a raw SQL query on the database.and thus use raw SQL to fetch all the table names. I take you know the SQL for that.
There also is a method
Connection::query_for_tables()
- Query for all tables in the current database. The result must only contain one column which has the name of the table.which might be doing what you are trying to do.