Update:Remora Database Replication

From MozillaWiki
Revision as of 02:15, 21 February 2007 by Sancus (talk | contribs)
Jump to navigation Jump to search
  • Method
    • Cake determines which db to use by the $useDbConfig var in the Model, so in order to implement rw/ro we need to change that var to the correct database. We default to the read-only Shadow db, and change to the default db only when performing a write operation, ideally, though some models may need to read from the rw db because they can't tolerate any replication lag.
    • We set a variable to store the name of the ro config, and the rw config as well, var $DbReadConfig and $DbWriteConfig.
    • This is pretty simple for the Save and Del methods.
function save($data = null, $validate = true, $fieldList = array()) {
    $this->useDbConfig=$this->useDbWriteConfig;
    $ret = parent::save($data, $validate, $fieldList);
    $this->useDbConfig=$this->useDbReadConfig;
    return $ret;
}