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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:38:23+00:00 2026-05-14T08:38:23+00:00

I have a Zend_Framework application, which has a whole bunch of model classes. I

  • 0

I have a Zend_Framework application, which has a whole bunch of model classes.

I need these model classes to be able to access the application’s database (naturally).

Currently I’ve put this in my index.php:

Zend_Registry::set('db',
        $application->bootstrap()->getBootstrap()
        ->getPluginResource('db')->getDbAdapter());

And then $db = Zend_Registry::get('db'); in each of my model classes that require the database.

But this seems like a horrible horrible hack. Am I missing something basic here?

  • 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-14T08:38:23+00:00Added an answer on May 14, 2026 at 8:38 am

    Example of setting up SQLITE in your application.ini. You can also setup for MySQL or others.

    resources.db.adapter = "PDO_SQLITE"
    resources.db.params.dbname = APPLICATION_PATH "/../data/db/guestbook.db"
    

    Once the db is loaded into the application you may extend the Zend_Db_Table_Abstract

    class Application_Model_DbTable_Guestbook extends Zend_Db_Table_Abstract
    {
        /** Table name */ 
        protected $_name    = 'guestbook';
    
        public function init() {
            $db = $this->getAdapter();
    
        }
    }
    

    You can use the zend methods…

            $select = $db->select()
             ->from(array('p' => 'products'),
                    array('product_id', 'product_name'))
             ->join(array('l' => 'line_items'),
                    'p.product_id = l.product_id');
    

    Or you can do straight sql…

    $sql = 'SELECT * FROM table1 t1 JOIN table2 t2 ON (t1.id = t2.id) JOIN table3 t3 ON (t3.id = t2.id);
    $db->query($sql)->fetchAll(); 
    

    All of this can be done in any model class that extends the Zend_Db_Table_Abstract

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

Sidebar

Related Questions

I have developed a Zend Framework application, which works well on xammp and windows.
Alright here's the situation, I have an application written in the Zend_Framework, that is
I have an application with multiple users with different roles. Each users access to
Iam coding a dating application for facebook. The application has to have a standalone
I have build a web application in Zend Framework and now desperately need a
I have a flash application which uses a single php file to retrieve records
I'm developing a system in which I have an entity 'program' which has some
I have a server which consists of several Zend Framework application. I want to
I have a Zend Framework application structure as below: /application /library /Zend /Core /Filter
I have a PHP MVC application using Zend Framework. As presented in the quickstart,

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.