public function __get($db)
{
if ($db == 'rlink') {
//如果没有指定从数据库,则使用 master
if (empty($this->conf['slaves'])) {
$this->rlink = $this->wlink;
return $this->rlink;
}
$n = mt_rand(0, count($this->conf['slaves']) - 1);
$conf = $this->conf['slaves'][$n];
empty($conf['engine']) && ($conf['engine'] = '');
$this->rlink = $this->connect($conf['host'], $conf['username'], $conf['password'], $conf['dbname'], $conf['charset'], $conf['engine'], $conf['pconnect']);
return $this->rlink;
} elseif ($db == 'wlink') {
$conf = $this->conf['master'];
empty($conf['engine']) && ($conf['engine'] = '');
$this->wlink = $this->connect($conf['host'], $conf['username'], $conf['password'], $conf['dbname'], $conf['charset'], $conf['engine'], $conf['pconnect']);
return $this->wlink;
}
return false;
}