Let’s assume we need to fetch data from direct database and we don’t want to use model in magento. At that time we can also access data direct from database using magento database connection and simple SQL query.
Below is the code for how can we access data using simple SQL query.
$new_db_resource = Mage::getSingleton('core/resource');
$connection = $new_db_resource->getConnection('magento');
$data='SELECT design_id FROM sales_flat_quote_item WHERE item_id = '.$_item->getId();
$outout=$connection->fetchRow($data);
print_r($outout);