1. <small id='hZjEI'></small><noframes id='hZjEI'>

      <i id='hZjEI'><tr id='hZjEI'><dt id='hZjEI'><q id='hZjEI'><span id='hZjEI'><b id='hZjEI'><form id='hZjEI'><ins id='hZjEI'></ins><ul id='hZjEI'></ul><sub id='hZjEI'></sub></form><legend id='hZjEI'></legend><bdo id='hZjEI'><pre id='hZjEI'><center id='hZjEI'></center></pre></bdo></b><th id='hZjEI'></th></span></q></dt></tr></i><div id='hZjEI'><tfoot id='hZjEI'></tfoot><dl id='hZjEI'><fieldset id='hZjEI'></fieldset></dl></div>
      <legend id='hZjEI'><style id='hZjEI'><dir id='hZjEI'><q id='hZjEI'></q></dir></style></legend>
        <bdo id='hZjEI'></bdo><ul id='hZjEI'></ul>
      <tfoot id='hZjEI'></tfoot>

    1. Zend Framework应用层的Master/Slave切换

      Master / Slave switch in the Zend Framework application layer(Zend Framework应用层的Master/Slave切换)

        <tfoot id='dVaHc'></tfoot>

      • <i id='dVaHc'><tr id='dVaHc'><dt id='dVaHc'><q id='dVaHc'><span id='dVaHc'><b id='dVaHc'><form id='dVaHc'><ins id='dVaHc'></ins><ul id='dVaHc'></ul><sub id='dVaHc'></sub></form><legend id='dVaHc'></legend><bdo id='dVaHc'><pre id='dVaHc'><center id='dVaHc'></center></pre></bdo></b><th id='dVaHc'></th></span></q></dt></tr></i><div id='dVaHc'><tfoot id='dVaHc'></tfoot><dl id='dVaHc'><fieldset id='dVaHc'></fieldset></dl></div>
          <tbody id='dVaHc'></tbody>
        <legend id='dVaHc'><style id='dVaHc'><dir id='dVaHc'><q id='dVaHc'></q></dir></style></legend>
          <bdo id='dVaHc'></bdo><ul id='dVaHc'></ul>
        • <small id='dVaHc'></small><noframes id='dVaHc'>

                本文介绍了Zend Framework应用层的Master/Slave切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在编写一个应用程序,它需要在应用程序层内进行主/从切换.就像现在一样,我在创建映射器时实例化一个 Zend_Db_Table 对象,然后 setDefaultAdapter 到从属设备.

                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.

                现在在基本映射器类中,我有以下方法:

                Now inside of the base mapper classe, I have the following method:

                public function useWriteAdapter()
                {
                    if(Zend_Db_Table_Abstract::getDefaultAdapter() != $this->_writeDb)
                    {
                        Zend_Db_Table_Abstract::setDefaultAdapter($this->_writeDb);
                        $this->_tableGateway = new Zend_Db_Table($this->_tableName);
                    }
                }
                

                我需要对此进行完整性检查.我不认为开销太大,我只是怀疑一定有更好的方法.

                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.

                推荐答案

                Zend_Db_Table_Row_Abstract 类型的对象会记住产生它的 Table 对象.但是您可以在调用 save() 之前更改关联的 Table.

                An object of type Zend_Db_Table_Row_Abstract remembers what Table object produced it. But you can change the associated Table before you call save().

                $readDb = Zend_Db::factory(...);  // replica
                $writeDb = Zend_Db::factory(...); // master
                Zend_Db_Table::setDefaultAdapter($readDb);
                
                $myReadTable = new MyTable(); // use default adapter
                $myWriteTable = new MyTable($writeDb);
                
                $row = $myTable->find(1234)->current();
                
                $row->column1 = 'value';
                
                $row->setTable($myWriteTable);
                
                $row->save();
                

                这篇关于Zend Framework应用层的Master/Slave切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                • <i id='npvS5'><tr id='npvS5'><dt id='npvS5'><q id='npvS5'><span id='npvS5'><b id='npvS5'><form id='npvS5'><ins id='npvS5'></ins><ul id='npvS5'></ul><sub id='npvS5'></sub></form><legend id='npvS5'></legend><bdo id='npvS5'><pre id='npvS5'><center id='npvS5'></center></pre></bdo></b><th id='npvS5'></th></span></q></dt></tr></i><div id='npvS5'><tfoot id='npvS5'></tfoot><dl id='npvS5'><fieldset id='npvS5'></fieldset></dl></div>

                        <legend id='npvS5'><style id='npvS5'><dir id='npvS5'><q id='npvS5'></q></dir></style></legend>
                          <bdo id='npvS5'></bdo><ul id='npvS5'></ul>
                          <tfoot id='npvS5'></tfoot>
                            <tbody id='npvS5'></tbody>

                          <small id='npvS5'></small><noframes id='npvS5'>