MyQEE\Server\Table::__construct PHP Method

__construct() public method

内存表
public __construct ( integer $size, string $link = null )
$size integer
$link string 连接,例如: mysql://user:[email protected]:3306/my_database/my_table?charset=utf8
    public function __construct($size, $link = null)
    {
        if ($size >= 1) {
            $size = bindec(str_pad(1, strlen(decbin((int) $size - 1)), 0)) * 2;
        } else {
            $size = 1024;
        }
        if ($link) {
            $p = parse_url($link);
            $p['scheme'] = strtolower($p['scheme']);
            if (!$p) {
                throw new \Exception("Can't parse this uri: " . $link);
            }
            switch ($p['scheme']) {
                case 'mysql':
                    $this->_type = $p['scheme'];
                    list($db, $table) = explode('/', trim($p['path']));
                    $p['db'] = $db;
                    $p['table'] = $table ?: 'memory_table';
                    $this->_column = [];
                    if ($p['query']) {
                        parse_str($p['query'], $query);
                        $p['query'] = $query ?: [];
                    }
                    break;
                    # todo 暂不支持 sqlite
                    //case 'sqlite':
                    //    $this->_type = $p['scheme'];
                    //    break;
                # todo 暂不支持 sqlite
                //case 'sqlite':
                //    $this->_type = $p['scheme'];
                //    break;
                case 'redis':
                case 'ssdb':
                case 'rocksdb':
                    $this->_type = $p['scheme'];
                    if (!$p['path']) {
                        $p['path'] = 'memory_table';
                    }
                    break;
                default:
                    throw new \Exception("The system does not support “{$p['scheme']}”");
            }
            $this->_link = $p;
        }
        parent::__construct($size);
    }