Engine23
blogBannerImage
By Engine23

Zend framework 1.x getting database config from application.ini

$configuration = new Zend_Config_Ini(
APPLICATION_PATH.'/configs/application.ini',
'development'
);
$host = $configuration->resources->db->params->host;
$pass = $configuration->resources->db->params->password;
$user = $configuration->resources->db->params->username;
$dbname = $configuration->resources->db->params->dbname;

$db = Zend_Db::factory('Pdo_Mysql', array(
'host' => $host,
'username' => $user,
'password' => $pass,
'dbname' => $dbname
));


//$resources = $data['resources'];
$sql = "SELECT * FROM school LIMIT 10";

$results = $db->fetchAll($sql);


foreach($results as $_result)
{
$a = $_result;
}