Thanks Paul! I love that you can have your test server, single db, and then
roll it into production. Very awesome! Also I was able to attend your talk
at PHP | Tek this year and it was awesome. Thanks for giving back to the PHP
community...it's appreciated!

Wade


On 6/25/09 9:47 AM, "Paul M Jones" <[email protected]> wrote:

> On Jun 24, 2009, at 02:49 , keith Pope wrote:
> 
>> 2009/6/24 wadearnold <[email protected]>:
>>> 
>>> I'm looking for a sanity check for my ZF connection to a mysql
>>> master/slave
>>> architecture. My Db configuration is MySQL Master and three slaves.
>>> The
>>> three slaves are behind a load balancer with linux hearbeat so to
>>> php the
>>> slaves are a single connection. To date I have been using two Zend_Db
>>> connections and then remembering in my code were to read and write:
>>> 
>>> // using mysqli adapter
>>> $master_db = Zend_Db::factory(...);
>>> $slave_db = Zend_Db::factory(...);
>>> 
>>> $master_db->insert(...);
>>> $master_db->beginTransaction();
>>> $master_db->update(...);
>>> 
>>> $slave_db->fetchAll(...)
>>> $slave_db->select(...)
>>> 
>>> 
>>> I have seen other frameworks abstract the first part of the sql
>>> statement
>>> and find the proper db pool. I am not sure if this is worthwhile
>>> and seems
>>> like a lot of work for PHP. There is not an equivalent in the Zend
>>> Framework
>>> correct?
>>> http://solarphp.com/class/Solar_Sql_Adapter_MysqlReplicated
>>> 
>>> I am starting a large application and don't want to come begging
>>> back to the
>>> list when it does not work. Does my implementation seem sufficient?
>>> Links to
>>> best practices would be great!
>> 
>> I would suggest doctrine, its far more mature than Zend_Db and has
>> support for what you are looking for
> 
> [FULL DISCLOSURE: I am the lead developer and architect of Solar, and
> was the initial developer of Zend_Db and Zend_Db_Table way back at the
> beginning.]
> 
> Per this Doctrine page ...
> 
>    
> http://www.doctrine-project.org/documentation/cookbook/1_1/en/master-and-slave
> -connections
> 
> ... it looks like there is no functional difference from the Zend_Db
> approach outlined above.  That is, you should create multiple
> connections, and pick manually which one you want to use.  The
> Doctrine example instructs you to do that in extended classes, which I
> guess Zend_Db is also capable of.
> 
> <selfpromotion>
> 
> This is as opposed to Solar's MysqlReplicated adapter, the SVN trunk
> version of which works automatically.  Yes, it examines the first few
> characters of the SQL statement to determine whether it should pick a
> master or a slave, which is not exactly a big performance drain.  It
> also manages GET-after-POST situations, so that if you insert or
> update on one request, the very next request *also* uses the master
> (even for reads), to allow time for data propagation to slaves.
> Finally, you can switch back and forth between replicated and non-
> replicated environments without changing your application code.
> 
> See more here:
> 
>    http://solarphp.com/blog/read/19-adapter-for-master-slave-my-sql-setups
> 
> </selfpromotion>
> 
> 
>> plus doctrine 2.0 (not released yet though) should have good support
>> for domain modeling...
> 
> Ah, the joys of unreleased software; it will do everything, just not
> yet.  ;-)
> 
> 

Reply via email to