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 7588771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:00:19+00:00 2026-05-30T20:00:19+00:00

I want to access to database mysql, I read that we can define the

  • 0

I want to access to database “mysql”, I read that we can define the db adapter and db configurations by writing these lines in application.ini file

resources.db.adapter = MYSQLI
resources.db.params.host = localhost
resources.db.params.username = root
resources.db.params.password =123456
resources.db.params.dbname = visits_db

I want to get the $db object in order to use in for executing sql statements

    $db->insert("inspection_visits_tb",
            $insepctionVisitData = array(
        'day' => $visit->getDay(),
        'date' => $visit->getDate(),
        'target' => $visit->getTarget()
    ));

I want to get it from the application.ini file not like this

require_once 'Zend/Db.php';
    $db = Zend_Db::factory("MYSQLI",
                    array(
                        "host" => "localhost",
                        "dbname" => "visits_db",
                        "username" => "root",
                        "password" => "123456")
    );

because I want to define the db adapter in one place only. What should I do to get the $db object??

  • 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-30T20:00:21+00:00Added an answer on May 30, 2026 at 8:00 pm

    Set up the db resource in application.ini like you were. Add the isDefaultAdapter option.

    resources.db.adapter = "MYSQLI"
    resources.db.params.host = "localhost"
    resources.db.params.username = "root"
    resources.db.params.password = "123456"
    resources.db.params.dbname = "visits_db"
    resources.db.isDefaultAdapter = true
    

    Then to get the $db object…

    In Bootstrap.php

    protected function _initDb()
    {
        $this->bootstrap('db');
        $db = $this->getResource('db');
        Zend_Registry::set('db', $db);
    }
    

    From Somewhere else w/out using Registry

    $db = Zend_Db_Table::getDefaultAdapter();
    

    Using Zend_Db_Table

    $table  = new Zend_Db_Table('bugs');
    $select = $table->select()...
    

    See also ZF Quickstart, Zend_Db_Table, Zend_Db_Select for more examples.

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

Sidebar

Related Questions

I want to access a MySQL database and I want to read+write data from+to
I want to access a MySQL database directly from JavaScript code in an HTML
I want to access a MySQL database from Java, but remote connection is disabled
I want to make a Windows service that will access my database. My database
I have read-only access to a remote MySQL database, which contains a very large
I have read-only access to a remote MySQL database, which contains a very large
I want to create two users on my MySQL test database, One with read-only
I want to add connection string to connect to mysql that are define in
I have a MySQL database set up on 000webhost.com. I want to access the
I am using Hibernate to access MySQL database for my java application. I configured

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.