Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7044629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:25:57+00:00 2026-05-28T02:25:57+00:00

i am new to zend framework i wana know why we are using this

  • 0

i am new to zend framework i wana know why we are using this code for connection to database although we can use the below code also which is simple and not including class what is the advantages of including Zend_config( )

require_once 'Zend/Config.php';
$arrConfig = array(
  'webhost'=>'localhost',
  'appName'=>'My First Zend',
  'database'=>array(
      'dbhost'=>'localhost',
      'dbname'=>'zend',
      'dbuser'=>'root',
      'dbpass'=>'admin'
      )
  );

$config = new Zend_Config($arrConfig);
$params = array('host'  =>$config->database->dbhost,
            'username'  =>$config->database->dbuser,
            'password'  =>$config->database->dbpass,
            'dbname'    =>$config->database->dbname
            );
$DB  = new Zend_Db_Adapter_Pdo_Mysql($params);
$DB->setFetchMode(Zend_Db::FETCH_OBJ);

if i can do like this

include_once 'Zend/Db/Adapter/Pdo/Mysql.php';
$params = array('host' => 'localhost',
        'username'  => 'root',
        'password'    => '',
        'dbname'        => 'zend'
           );
 $DB = new Zend_Db_Adapter_Pdo_Mysql($params);
 $DB->setFetchMode(Zend_Db::FETCH_OBJ);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:25:57+00:00Added an answer on May 28, 2026 at 2:25 am

    in the way you’re using Zend_Config it’s in fact doesn’t help you a lot to have the settings in a config object.

    Usually, in ZF applications, there’s a separate application.ini file which contains all the settings:

    $config = new Zend_Config_Ini('/path/to/config.ini',
                                  'production');
    

    Then it’s convenient to separate environments (production & development for example) into different sections:

    ; Production site configuration data
    [production]
    database.adapter         = pdo_mysql
    database.params.host     = db.example.com
    database.params.username = dbuser
    database.params.password = secret
    database.params.dbname   = dbname
    
    ; Development site configuration data inherits from production and
    ; overrides values as necessary
    [development : production]
    database.params.host     = dev.example.com
    database.params.username = devuser
    database.params.password = devsecret
    

    meaning loading the config with:

    $config = new Zend_Config_Ini('/path/to/config.ini',
                                  'development');
    

    wil return the development config.

    http://framework.zend.com/manual/en/zend.config.adapters.ini.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to zend framework. I have write this code to set cookie
I'm new to Zend Framework. I would like to know how to implement zend
I'm learning zend framework from zendCast and can't find the problem I'm using: -Zend
I'm using Zend Framework for PHP and handling sessions with the Zend_Session module. This
Im new to Zend framework, i would like to know how to add a
I am using sessions in zend framework. the question is i need to know
I'm new to zend framework so maybe this question is stupid.. I've got a
I'm interested in using Doctrine as an ORM for a new Zend Framework app
I'm looking at some Zend Framework code a developer I'm working with is using,
I have a pretty weird problem related to zend framework's zend_db. I use $this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.