Monday, 16 March 2015

Accessing The Database in magento


Accessing The Database
When I initially found out how to create an external database connection, I was using Zend_Db to retrieve all of my information. You can use the following to test your database connection is working:
1
2
3
4
5
6
7
<?php

    $resource   = Mage::getSingleton('core/resource');
    $conn       = $resource->getConnection('externaldb_read'); db name
    $results    = $conn->query('SELECT * FROM tblName'); sql
   
  print_r($results)

?>







No comments:

Post a Comment