Resolve how to connect to a database using Zend Framework


$db = Zend_Db::factory('Pdo_Mysql', array(
                               'host'     => '127.0.0.1',
                               'username' => 'root',
                               'password' => '123456',
                               'dbname'   => 'mysql'
     ));

A direct connection to MYSQL returns a database connection object Read the configuration in the configuration file and connect

$config = new Zend_Config_Ini('config.ini', 'main');    // Read the analysis Zend Configuration file, main Represents the parent of the configuration file
$params['profiler'] = $config->db->profiler;            // Assign database connection information
$db = Zend_Db::factory('PDO_MYSQL', $params);           // Connect to database