Generate Grand Vision

@param mixed ...$database
494558
public function generate(...$database)
    {
        $databases = $this->getDatabaseList($database);

        foreach( $databases as $connection => $database )
        {
            $this->setDatabaseConfiguration($connection, $database, $configs);

            $this->createVisionDirectoryByDatabaseName($database);

            $this->createVisionModelFile($database, $configs);
        }
    }
942220
public function getSchemaYAMLFile($database)
    {
        $dir = $this->loader->find($this->application->config('directory.database.schema'))->first();
        return $dir . DS . $this->schemaYAMLFileNameStrategy($database);
    }
209957
public function actionRecreateViews ()
		{
			$db = Yii::$app->db;
			$views = $this->getViews();

			foreach ($views as $view)
			{
				$info = $db->createCommand("SHOW CREATE VIEW `$view`")->queryAll();
				$sql = $info[ 0 ][ 'Create View' ];
				preg_match("/.*VIEW `$view` as (.*)/i", $sql, $match);
				if (isset($match[ 1 ]))
				{
					$db->createCommand("CREATE OR REPLACE VIEW `$view` AS " . $match[ 1 ])->execute();
					Console::printColor("View `$view` was recreated.", "green");
				}
				else
				{
					Console::printColor("Cannot find create string for view `$view`.", "red");
				}
			}
		}
829790
protected function isLoaded($table = null, $database = null)
    {
        //if no table
        if (is_null($table)) {
            //if no default table either
            if (!$this->table) {
                return false;
            }
            
            $table = $this->table;
        }
        
        //if no database
        if (is_null($database)) {
            //and no default database
            if (!$this->database) {
                return false;
            }
            
            $database = $this->database;
        }
        
        $meta = $this->getMeta($table, $database);
        
        return $this->isPrimarySet($meta[self::PRIMARY]);
    }
504309
protected function addSequences(Database $database)
    {
        $searchPath = '?';
        $params = [$database->getSchema()];
        if (!$database->getSchema()) {
            $stmt = $this->dbh->query('SHOW search_path');
            $searchPathString = $stmt->fetchColumn();

            $params = [];
            $searchPath = explode(',', $searchPathString);

            foreach ($searchPath as &$path) {
                $params[] = $path;
                $path = '?';
            }
            $searchPath = implode(', ', $searchPath);
        }

        $stmt = $this->dbh->prepare("
            SELECT c.relname, n.nspname
            FROM pg_class c, pg_namespace n
            WHERE
                n.oid = c.relnamespace
            AND c.relkind = 'S'
            AND n.nspname IN ($searchPath);
        ");
        $stmt->execute($params);

        while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
            $name = $row['nspname'] . '.' . $row['relname'];
            $database->addSequence($name);
        }
    }
623891
private function _checkdatabase($database)
    {

        if (count($this->_collection) == 0) {
            $this->_collection[$database] = new $database();

            return $this->_collection[$database];
        }

        $new = false;
        foreach ($this->_collection as $db) {
            if ($db === $database) continue;
            $new = true;
        }

        if ($new === true) {
            $this->_collection[$database] = new $database();
        }

        return false;
    }
879937
public function sqlGenerate(string $sql, array $params = []): \Generator
    {
        yield from $this->connection()->sqlGenerate($sql, $params);
    }
839035
public function getTables($database=null)
    {
        if (empty($database)) $database = $this->getDatabase();
        
        $key  = 'db/tables/' . $database;
        $data = static::getCache()->get($key);
        if (!$data) {
            $data = $this->getAdapter()->getTables($database);
            static::getCache()->set($key, $data);
        }
        return $data;
    }
947971
public function generateViews()
    {
        $viewPath = $viewExtension = '';
        $viewDir = $this->command->applicationDir.DS.'Views'.DS.$this->controller;
        $this->hasDirectory($viewDir);

        $viewExtension = ($this->layoutType == 'php') ? self::EXTENSION : self::TWIG_EXTENSION;
        $viewType = ($this->layoutType == 'php') ? 'Php'.DS : '';

        foreach ($this->views as $key => $view) {
            $viewPath = $this->viewTemplatePath.'controller'.DS.$viewType.$view.self::TEMP_EXTENSION;
            $this->readContents($viewPath, $view);
            $this->generate($view.$viewExtension);
        }
    }
1241642
public function getBuildConnection($database)
    {
        if (!isset($this->buildConnections[$database])) {
            // fallback to default connection settings from build.properties
            return array(
                'dsn'      => $this->url,
                'user'     => $this->userId,
                'password' => $this->password,
            );
        }

        return $this->buildConnections[$database];
    }
62206
protected function runSeeder($database)
	{
		$class = $this->option('seeder') ?: 'DatabaseSeeder';

		$force = $this->input->getOption('force');

		$this->call('db:seed', array(
			'--database' => $database, '--class' => $class, '--force' => $force,
		));
	}
100469
public function createCommand($db = null)
    {
        if ($this->primaryModel !== null) {
            // lazy loading
            if (is_array($this->via)) {
                // via relation
                /* @var $viaQuery ActiveQuery */
                list($viaName, $viaQuery) = $this->via;
                if ($viaQuery->multiple) {
                    $viaModels = $viaQuery->all();
                    $this->primaryModel->populateRelation($viaName, $viaModels);
                } else {
                    $model = $viaQuery->one();
                    $this->primaryModel->populateRelation($viaName, $model);
                    $viaModels = $model === null ? [] : [$model];
                }
                $this->filterByModels($viaModels);
            } else {
                $this->filterByModels([$this->primaryModel]);
            }
        }

        /* @var $modelClass ActiveRecord */
        $modelClass = $this->modelClass;
        if ($db === null) {
            $db = $modelClass::getDb();
        }

        if ($this->type === null) {
            $this->type = $modelClass::type();
        }
        if ($this->index === null) {
            $this->index = $modelClass::index();
            $this->type = $modelClass::type();
        }
        $commandConfig = $db->getQueryBuilder()->build($this);

        return $db->createCommand($commandConfig);
    }
789727
public function addDatabase(Database $database)
    {
        if (isset($this->databases[$database->getName()])) {
            throw new DBALException("Database '{$database->getName()}' already exists");
        }

        $this->databases[$database->getName()] = $database;
    }
359040
public function stopDatabase($database)
    {
        assert($this->_platform instanceof SQLAnywherePlatform);
        $this->_execSql($this->_platform->getStopDatabaseSQL($database));
    }
603636
private function parseDatabaseCommand(string &$database)
    {
        if (input()->hasSOpt('d') || input()->hasLOpt('database')) {
            $database = (string)\input()->getSameOpt(['d', 'database']);
        }
    }
1054876
public function generateAction()
    {
        // Update Database
        $this->sqlCodeGenerator->updateDatabase();

        // Clear system cache to force new TCA caching
        $cacheManager = GeneralUtility::makeInstance(CacheManager::class);
        $cacheManager->flushCachesInGroup('system');
    }
1228364
protected function makeDatabase(DatabasePartial $database): Database
    {
        return new Database(
            $database->getName(),
            $database->getPrefix(),
            $this->driver($database->getDriver()),
            $database->getReadDriver() ? $this->driver($database->getReadDriver()) : null
        );
    }