In order to run a SQL query against the Magento database, you first need a resource model then a database connection.
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<?php $db = Mage::getResourceSingleton('core/resource')->getConnection('core_write'); $result = $db->query('SELECT 'entity_id' FROM 'catalog_product_entity'); if (!$result) { return FALSE; } $rows = $result->fetch(PDO::FETCH_ASSOC); if (!$rows) { return FALSE; } print_r($rows); ?> |