One minute
PHP / Magento - Direct SQL Queries
👴 Careful You’re reading an old article ! Some links might be broken and content may be outdated
Not the cleanest but here’s a quick solution to do a direct query on Magento. Might be faster than calling Magento’s objects ?
/**
* Get the resource model
*/
$resource = Mage::getSingleton('core/resource');
/**
* Acccess to the database in read only
*/
$readConnection = $resource->getConnection('core_read');
$query = 'SELECT * FROM ' . $resource->getTableName('catalog/product');
/**
* Execute the query
*/
$results = $readConnection->fetchAll($query);
Read other posts