静态化,工厂方法
因为本类的子类要使用instance创建实例对象,但参数不同,
导致本方法不能使用instance作为方法名

@param string $alias
@param string $cacheType
@return Table      注:就是Table,而不是TableCache
764509
static public function getInstance(string $alias, ?string $cacheType = null): Table
    {
        // 保存每个表对象
        static $tables = [];

        // 如果尚未创建,则创建并缓存
        if (!isset($tables[$alias])) {
            $tables[$alias] = new static($alias, $cacheType);
        }

        // 返回缓存后的表对象
        return $tables[$alias];
    }
268143
public function setSQLTableAlias($tableName, $alias, $dqlAlias = '')
    {
        $tableName .= $dqlAlias ? '@[' . $dqlAlias . ']' : '';

        $this->tableAliasMap[$tableName] = $alias;

        return $alias;
    }
187743
public function findActiveByAlias($alias)
    {
        $query = $this->createValuedQueryBuilder('c')
            ->where('c.alias = :alias')
            ->andWhere('c.active = :active')
            ->setParameters(['alias' => $alias, 'active' => true])
            ->getQuery();

        return $query->useResultCache(true, self::CACHE_TTL)->getSingleResult();
    }
1065272
public function buildCache($table = null, $key = null, $cache = null)
    {
        if ($this->sql &&
            ($table === null || $this->setTableName($table)) &&
            ($key === null || $this->setKeyName($key)) &&
            ($cache === null || $this->setCacheName($cache))) {
            if ($this->sql->query("
                CREATE TABLE IF NOT EXISTS `{$this->table}` (
                    `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
                    `{$this->key}` text NOT NULL,
                    `{$this->cache}` longtext NOT NULL,
                    `expire` timestamp NULL DEFAULT NULL,
                    `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
                    PRIMARY KEY (`id`)
                );
            ")) {
                $this->initialized = true;

                /* Upgrade older cache tables for longer cache data */
                $this->sql->query("
                    ALTER TABLE `{$this->table}` CHANGE `{$this->cache}` `{$this->cache}` longtext NOT NULL;
                ");

                /* Upgrade older cached tables to include an expire column for each row */
                $this->sql->query("
                    ALTER TABLE `{$this->table}` ADD `expire` timestamp NULL DEFAULT NULL AFTER `{$this->cache};
                ");
            }
        }
        return $this->initialized;
    }
955173
public function get($alias, $default = false, $config = array())
	{
		$result = wincache_ucache_get ($alias,$success);
		if(false === $success)
		{
			return $this->parseDefault($default);
		}
		else
		{
			return $result;
		}
	}
604650
public static function cacheExists($cacheName, $option = array(), $alias = null)
	{
		$obj = self::getInstance($alias);
		if ($obj)
		{
			return $obj->exists($cacheName, $option);
		}
		else
		{
			return false;
		}
	}
626549
public function get($alias, $default = false, $config = array())
	{
		$tableName = $this->cache->parseField($this->tableName);
		$key = $this->cache->parseField('key');
		$expire = $this->cache->parseField('expire');
		$time = time();
		$result = $this->cache->query(<<<SQL
select * from {$tableName} where {$key} = %s and ({$expire} = 0 or {$expire} >= {$time})
SQL
,array($alias));
		if(isset($result['key']))
		{
			return $result['value'];
		}
		else
		{
			return $this->parseDefault($default);
		}
	}
960972
public function getDriver($alias)
    {
        try {
            if ($alias == "Auth") {
                $driver = \Auth::driver();
            } elseif ($alias == "DB") {
                $driver = \DB::connection();
            } elseif ($alias == "Cache") {
                $driver = get_class(\Cache::driver());
                $store = get_class(\Cache::getStore());
                return array($driver, $store);
            } elseif ($alias == "Queue") {
                $driver = \Queue::connection();
            } else {
                return false;
            }

            return get_class($driver);
        } catch (\Exception $e) {
            $this->error("Could not determine driver/connection for $alias.");
            return false;
        }
    }
1082361
public function createResultSetMappingBuilder($alias)
    {
        $rsm = new ResultSetMappingBuilder($this->em, ResultSetMappingBuilder::COLUMN_RENAMING_INCREMENT);
        $rsm->addRootEntityFromClassMetadata($this->entityName, $alias);

        return $rsm;
    }
200481
public function from($table, $alias = null)
    {
        if ($table) {
            if (!$this->_model && strpos($table, '\\') !== false) {
                $this->_model = $this->_di->getShared($table);
            } else {
                $this->_source = $table;
            }
        }

        return $this;
    }
758381
protected function getPageCache($cache_type)
    {
        $route_info = Lb::app()->getRouteInfo();
        $page_cache_key = implode('_', ['page_cache', $route_info['controller'], $route_info['action']]);
        return Lb::app()->getCache($page_cache_key, $cache_type);
    }
863153
public function join($table, $alias = null, $on = null, $type = 'INNER JOIN')
    {
        $table = $this->connection->quoteIdentifier($table);

        $this->joins[$alias] = "$type $table $alias ON $on";

        return $this;
    }
983203
public function table($table, $alias = null)
    {
        $database = null;

        // Check if the table is an object, this means
        // we have an subselect inside the table
        if (is_object($table) && ($table instanceof \Closure)) 
        {
            // we have to check if an alias isset 
            // otherwise throw an exception to prevent the 
            // "Every derived table must have its own alias" error
            if (is_null($alias))
            {
                throw new Exception('You must define an alias when working with subselects.');
            }

            $table = array($alias => $table);
        } 

        // Check if the $table is an array and the value is an closure
        // that we can pass a new query object as subquery 
        if (is_array($table) && is_object(reset($table)) && (reset($table) instanceof \Closure)) 
        {
            $alias = key($table);
            $table = reset($table);

            // create new query object
            $subquery = new Select;

            // run the closure callback on the sub query
            call_user_func_array($table, array(&$subquery));

            // set the table 
            // IMPORTANT: Only if we have a closure as table
            // we set the alias as key. This might cause some confusion
            // but only this way we can keep the normal ['table' => 'alias'] syntax
            $table = array($alias => $subquery);
        } 

        // other wise normally try to split the table and database name
        elseif (is_string($table) && strpos($table, '.') !== false)
        {
            $selection = explode('.', $table);

            if (count($selection) !== 2)
            {
                throw new Exception( 'Invalid argument given. You can only define one seperator.' );
            }

            list($database, $table) = $selection;
        }

        // the table might include an alias we need to parse that one out 
        if (is_string($table) && strpos($table, ' as ') !== false)
        {
            $tableParts = explode(' as ', $table);
            $table = array($tableParts[0] => $tableParts[1]);
        }

        // assing the result
        $this->database = $database;
        $this->table = $table;

        // return self
        return $this;
    }
449263
private function getCacheFile($type)
    {
        $type = str_replace(EntityMetadata::NAMESPACE_DELIM, '_', $type);
        return $this->dir.'/ModlrData.'.$this->cachePrefix.'.'.$type.'.'.$this->extension;
    }
322761
public function addTable($alias, $table, $condition = null, $joinType = 'LEFT', $prefix = null)
    {
        $tableStorage = [];

        $tableStorage['name'] = $table;
        $tableStorage['join'] = strtoupper($joinType);

        $condition = trim((string) new QueryElement('', (array) $condition, ' AND '));

        if (!$condition) {
            $tableStorage['join'] = 'FROM';
        }

        // Remove too many spaces
        $condition = preg_replace('/\s(?=\s)/', '', $condition);

        $tableStorage['condition'] = $condition;
        $tableStorage['prefix'] = $prefix;

        $this->tables[$alias] = $tableStorage;

        return $this;
    }
1191299
public function From(string $table, string $alias = ''): QueryBuilder
    {
        $this->table = $table;
        
        if (! empty($alias)) {
            $this->alias = $alias;
        }
        
        return $this;
    }
1128460
public function from($table, $alias = null)
    {
        if ($table) {
            if (!$this->_model && strpos($table, '\\') !== false) {
                $this->_model = $this->_di->getShared($table);
            }

            $this->_tables = $alias ? [$alias => $table] : [$table];

            if ($table instanceof self) {
                $this->_db = $table->_db;
            }
        }

        return $this;
    }