The code explain every thing
//this for all error reporting
error_reporting(E_ALL|E_STRICT);
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
//database
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
//to store the object/array/var in system use the register
require_once 'Zend/Registry.php';
//this for mysql connection
require_once 'Zend/Db/Adapter/Pdo/Mysql.php';
Zend_Registry::set('varname',"value of var");
//there are two way of setting the database connection
//first by setting the using the Zend_Db_Adapter_Pdo_Mysql
//second using the Zend_Db:factory
/*$params = array('host'
=>'localhost',
'username'
=>'root',
'password' =>'password',
'dbname'
=>'zend'
);
$db=new Zend_Db_Adapter_Pdo_Mysql($params);
$db->setFetchMode(Zend_Db::FETCH_OBJ);*/
//this for load the application varibles,first parametes is application ini path & second is
//blok in application ini
$config=new Zend_Config_Ini(APPLICATION_PATH.'/configs/application.ini','general');
$db= Zend_Db::factory($config->db->adapter,$config->db->params->toArray());
Zend_Registry::set('db',$db);
$application->bootstrap()
->run();