Re: Re: Pear DB on mysql replication cluster
| From: | Alberto M | Date: | Fri, 28 Nov 2003 12:29:05 +0000 |
| Subject: | Re: Re: Pear DB on mysql replication cluster | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-23951@lists.php.net to get a copy of this message | ||
Michael Wallner wrote:
Hi Alberto M, you wrote:little more deeply we can work on $dsn[] pool directly, or defer it to an object or directly into DB class. i mean, suppose we have: $dsn['master'] = 'mysql://hostmaster/testdb'; $dsn['slave'] = 'mysql://hostslave/testdb'; one methods is, when you have a manipulation query, do it in the master, while do it in the slave: assume we have an sql statement in $sql $sql = "..."; if (DB::isManip($sql)) $db =& DB::connect($dsn['master']); else $db =& DB::connect($dsn['slave']); $res = $db->query($sql); another way could be to handle $dns as an object that could be used into DB::query() when the object has to choose which dsn to use. but the connection is maybe still available, so it needs to be changed if it doesn't fit our need (master/manip - slave/no_manip), right? or, we can also open at the beginning of the script N different db connections, where N=count($dsn) and defer the choice to the code, but this is not good whenever. instead, we can choose before coding, that some manipulations scripts have to go on master, and, for instance statistics scripts, some other have to go on slave. but would be better if we defer it to an object that, given informations about the dsn pool and the each one "choiche-weigth", might choose the one that should be used in that moment. also, using object we can move control from application to the library layer, so anyone could easily manage it. this is what I would, of course it's a personal idea, but has become by my experience. could be useful to create a different DB_mysql object, such as DB_mysql_cluster? bye, alberto. -- "Imagination is more important than knowledge"does someone would give me a hint on how to implement it?I would implement my own simple DataAccess objects in which I could easily run reading queries against the replicas and manipulative queries against the master server. Just a thought... Regards,