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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:22:43+00:00 2026-05-12T17:22:43+00:00

I have a project in which I use more than one adapter. So In

  • 0

I have a project in which I use more than one adapter.
So In ma models i created an abstract model

abstract My_Config1_Model extends Zend_Db_Table_Abstract 
{

    public function init()
    {
     $db = Zend_Registry::get('dbcon')->getDb(Kiga_Data_Database::MASTER);
     $this->setDefaultAdapter($db);
    }

}

and then I inherit this abstaract class like:

class MyModel extends My_Config1_Model
{

        protected $_name = 'mytable';

 protected $_primary = 'id';

 protected $_rowClass = 'MyRow';

}


class MyRow extends Zend_Db_Table_Row_Abstract 
{

}

and the in my controller I try:

$table = new MyModel();

when I fetch alll it works:

$results = $table->fetchAll(); // works fine

but when I try to filter it it does not work:

results = $table->fetchRow(“id = 1”); // Does not work. I get the error Error: No adapter for type MyRow.

Anybody any Idea?
Thanks.

I forgot I use also paginator

$paginator = Zend_Paginator::factory($results);
  • 1 1 Answer
  • 1 View
  • 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-12T17:22:43+00:00Added an answer on May 12, 2026 at 5:22 pm

    That’s not the place you should set the Db adapter for this table.

    The init() method is called after the table class has parsed its options and set up the adapter for the table. So all you’ve accomplished is to set the default Db adapter for subsequent table construction, but it has no effect on the current table if you do this in the init() method.

    Consider this simplified example:

    class MyTable
    {
      static $defaultDb;
      protected $db;
    
      static function setDefaultDb($db) { self::$defaultDb = $db; }
    
      public function __construct() {
        $this->db = self::$defaultDb;
        $this->init();
      }
    
      public function init() {
        // Unfortunately, PHP allows you to run static methods 
        // as if they are non-static methods, which is confusing.  
        $this->setDefaultDb($globalDb);
      }
    }
    

    This example is a simplified model of the way Zend_Db_Table constructs. Note that the init() method sets the class default Db, but this is run after the constructor has already set the instance Db to be the class default Db. So setting the class default Db has no effect.

    There are several ways you can set the Db adapter for a table:

    • For all tables, using the static method setDefaultAdapter(). The intended way to use setDefaultAdapter() is as follows:

      Zend_Db_Table_Abstract::setDefaultAdapter($db);
      // now all tables will use $db by default
      $table = new MyModel();
      
    • As a constructor argument:

      $table = new MyModel(array('db'=>$db));
      
    • You might also be able to use the setOptions() method after the table class has been instantiated.

      $table = new MyModel(); // uses default Db
      $table->setOptions(array('db'=>$otherDb));
      

      But be aware that the table reads its metadata from the default Db during construction, so if you change the adapter subsequently, the table should be defined identically in both databases.

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

Sidebar

Related Questions

I have a project which exposes object model to use by different types of
I’m starting a multi project solution that will have more than one entry point,
I have an existing project repo which I use for project A, and has
I have a project which I am trying to use in another new project,
I have a project in which I'd like to use some of the .NET
I use LINQ-SQL as my DAL, I then have a project called DB which
In my testing project, I have a static class called FixtureSetup which I use
I have a DLL project in VS 2008 Pro which uses OpenMP. I use
I have an MVC3 project for which I use NinjectMVC3 for dependency injection -
I have been working on a project which is about data copy from one

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.