cancel
Showing results for 
Search instead for 
Did you mean: 

Call The Table Prefix

SOLVED

Call The Table Prefix

Hello

 

It's me again as you know i'm new in Magento and something is disturbing me i'm searching a way to call the database prefix set in the begining of the installation like _DB_PREFIX_ in Prestashop but every post i saw about this wasn't really clear and very complicated for something that simple can someone tell me if there is a simple way pls ? 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Call The Table Prefix

@Antoine553

 

If you want to get table name into your install schema then use below link for reference

 

https://mage2.pro/t/topic/529/2


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

View solution in original post

3 REPLIES 3

Re: Call The Table Prefix

You can get tablename like below way,

$obj = \Magento\Framework\App\ObjectManager::getInstance();
$connection = $obj->get('Magento\Framework\App\ResourceConnection')->getConnection();
$prefixTablename = $connection->getTableName('tablename'); // pass your tablename
echo $prefixTablename;

Please let me know if you have query or I am wrong.


If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial

Re: Call The Table Prefix

@Antoine553

 

If you want to get table name into your install schema then use below link for reference

 

https://mage2.pro/t/topic/529/2


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

Re: Call The Table Prefix

thanks you