Get Table Name in Magento

I am writing here a small but useful snippet of code, for getting the table name of any module (whose table name are defined in config file).

This is very useful when using joins in query.

Suppose my module is ‘vendor’.

<?php

$resource = Mage::getSingleton('core/resource');
$tableName = $resource->getTableName('vendor/vendor');


?>

2 thoughts on “Get Table Name in Magento

  1. Hi! i need to see list of table name in Sales Order

    $getQuote = Mage::getSingleton(‘sales/order’);
    $getTableName = $getQuote->getTableName(‘sales/sales’);
    print_r($getTableName);

    is it correct way? but it not work me

    1. Its not correct

      Use this

      $resource = Mage::getSingleton('core/resource');
      $tableName = $resource->getTableName('sales/order');
      

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top