title: Master / Slave switch in the Zend Framework application layer
body: <p>I am writing an application which requires the Master/Slave switch to happen inside the application layer. As it is right now, I instantiate a Zend_Db_Table object on creation of the mapper, and then setDefaultAdapter to the slave. </p>
  
  <p>Now inside of the base mapper classe, I have the following method:</p>
  
  <pre><code>public function useWriteAdapter()
  {
      if(Zend_Db_Table_Abstract::getDefaultAdapter() != $this-&gt;_writeDb)
      {
          Zend_Db_Table_Abstract::setDefaultAdapter($this-&gt;_writeDb);
          $this-&gt;_tableGateway = new Zend_Db_Table($this-&gt;_tableName);
      }
  }
  </code></pre>
  
  <p>I need a sanity check on this.  I don't think the overhead is too much, I just suspect there must be a better way.</p>