db_pdo_mysql::connect_slave PHP Метод

connect_slave() публичный Метод

连接从服务器,如果有多台,则随机挑选一台,如果为空,则与主服务器一致。
public connect_slave ( )
    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;
    }