Magento 1.9 – How to Get Database Table Names

magento-1.9

I need to add some checks on database all tables for this want to get all tables name which are exist in database.

Is there any way to get all tables name from database in magento1.9?

Best Answer

$connection = Mage::getModel('core/resource')->getConnection('core_read');
$sql = 'SELECT TABLE_NAME 
        FROM INFORMATION_SCHEMA.TABLES
        WHERE TABLE_TYPE = "BASE TABLE" AND TABLE_SCHEMA="magento1" '; //your db name
$names = $connection->fetchAll($sql);
Mage::log($names, null, "db.log");

Try this

Related Topic