Maybe i have a easy suggestion:
1) Extend Zend_Db_Table and use the Slaves Database as default adapter.
2) overwrite the insert, update and delete functions and use the "Master"
adapter
Something like:
Class My_Db_Table extends Zend_Db_Table
{
(...)
Public function insert($data)
{
$this->setDefaultAdapter(--Master Db Adapter--);
return parent::insert($data);
}
(...)
}
And extend all table classes from My_Db_Table
-----Mensaje original-----
De: Karol Grecki [mailto:[EMAIL PROTECTED]
Enviado el: jueves, 16 de octubre de 2008 13:15
Para: [email protected]
Asunto: Re: [fw-general] Database profiles for reading/writing with Zend_Db
Xavier Vidal Piera wrote:
>
> Hi
>
> Talking about scalability and database replication, i'm looking forward to
> setup an application that will use a MySQL Master and a couple of MySQL
> Slaves.
>
> At the moment my ZF actual setup is using only one Database Adapter but
> we're moving to a new setup using replication.
>
> Is Zend_Db_Table ready to manage this kind of replication setups? As a
> example, now a Zend_Db_Table_Row will save and update rows using the same
> connection. A useful feature will be if zend_db_table / zend_db_table_row
> can detect if there are more than one database profile and use them based
> in
> reading / writing.
>
> Can anyone provide more info about this term?
>
It's not build into Zend_Db but you should be able to implement it yourself
quite easily.
The problem is that sending all read queries to slaves might not work very
well.
Because of the replication lag you may show stale data after users edits his
profile etc.
It may be better to switch adapters in your application based on the
context, use master
if you need write & read and slave for cases where data is only read, like
reporting.
Karol
--
View this message in context:
http://www.nabble.com/Database-profiles-for-reading-writing-with-Zend_Db-tp2
0010673p20011604.html
Sent from the Zend Framework mailing list archive at Nabble.com.