Cml\Db\Base::__get PHP Метод

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

魔术方法 自动获取相应db实例
public __get ( string $db ) : resource | false
$db string 要连接的数据库类型
Результат resource | false 数据库 连接标识
    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;
    }