Thursday, September 2, 2010

How to create the application.ini in zend

 The code explain every thing
//this for all error  reporting
// Define path to application directory
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

// Define application environment
    || 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'),


/** Zend_Application */
require_once 'Zend/Application.php';

// Create application, bootstrap, and run
$application = new Zend_Application(
    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);
//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());


No comments:

Post a Comment