public function connect_slave()
{
if ($this->rlink) {
return $this->rlink;
}
if (empty($this->conf['slaves'])) {
if (!$this->wlink) {
$this->wlink = $this->connect_master();
}
$this->rlink = $this->wlink;
} else {
$n = array_rand($this->conf['slaves']);
$conf = $this->conf['slaves'][$n];
$this->rlink = $this->real_connect($conf['host'], $conf['user'], $conf['password'], $conf['name'], $conf['charset'], $conf['engine']);
}
return $this->rlink;
}