Searches for tables in the database. Maybe we want to search also the views.
@param Database $database The Database model class to add tables to.
@param Table[]  $additionalTables
973151
public function parse(Database $database, array $additionalTables = [])
    {
        $tables = [];
        $stmt = $this->dbh->query("SELECT OBJECT_NAME FROM USER_OBJECTS WHERE OBJECT_TYPE = 'TABLE'");

        $seqPattern = $this->getGeneratorConfig()->get()['database']['adapters']['oracle']['autoincrementSequencePattern'];

        // First load the tables (important that this happen before filling out details of tables)
        while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
            if (false !== strpos($row['OBJECT_NAME'], '$')) {
                // this is an Oracle internal table or materialized view - prune
                continue;
            }
            if (strtoupper($row['OBJECT_NAME']) === strtoupper($this->getMigrationTable())) {
                continue;
            }
            $table = new Table($row['OBJECT_NAME']);
            $table->setIdMethod($database->getDefaultIdMethod());
            $database->addTable($table);
            // Add columns, primary keys and indexes.
            $this->addColumns($table);
            $this->addPrimaryKey($table);
            $this->addIndexes($table);

            $pkColumns = $table->getPrimaryKey();
            if (1 === count($pkColumns) && $seqPattern) {
                $seqName = str_replace('${table}', $table->getName(), $seqPattern);
                $seqName = strtoupper($seqName);

                $stmt2 = $this->dbh->query("SELECT * FROM USER_SEQUENCES WHERE SEQUENCE_NAME = '" . $seqName . "'");
                $hasSeq = $stmt2->fetch(\PDO::FETCH_ASSOC);

                if ($hasSeq) {
                    $pkColumns[0]->setAutoIncrement(true);
                    $idMethodParameter = new IdMethodParameter();
                    $idMethodParameter->setValue($seqName);
                    $table->addIdMethodParameter($idMethodParameter);
                }
            }

            $tables[] = $table;
        }

        foreach ($tables as $table) {
            $this->addForeignKeys($table);
        }

        return count($tables);
    }
576661
private void addTables()
    {
        for (final SQLTable table : getType().getTables()) {
            if (!getTable2values().containsKey(table)) {
                getTable2values().put(table, new ArrayList<Value>());
            }
        }
    }
799269
public void addDatabase(Database database)
    {
        this.getDatabaseList((database.getDatabaseType() & DBConstants.TABLE_MASK)).put(database.getDatabaseName(false), database);
    }
1303193
public function getTables ($db)
	{
		
		// Get tables
		
		if (!isset ($this->tables[$db]))
		{
			
			$query	= $this->db->query ('SHOW TABLES FROM ' . $db);
			$query->setFetchMode (\PDO::FETCH_COLUMN, 0);
			
			$this->tables[$db]	= $query->fetchAll ();
			
		}
		
		// Return tables
		
		return $this->tables[$db];
		
	}
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;
    }
1197141
public function initDb(array $connections): void{
        $this->db = new Database();
        foreach ($connections as $name => $settings) {
            $this->db->addConnection($settings, $name);
        }
    }
556389
protected function _select_db($database)
	{
		if ( ! mysql_select_db($database, $this->_connection))
		{
			// Unable to select database
			throw new \Database_Exception(mysql_error($this->_connection), mysql_errno($this->_connection));
		}

		static::$_current_databases[$this->_connection_id] = $database;
	}
704318
public function complete_sql($sql = null, array $params = [], array $extra_params = [])
    {
        if (func_num_args()) {
            if (isset($extra_params['page']))
                $this->page = $extra_params['page'];
            if (isset($extra_params['perPage']))
                $this->limit = $extra_params['perPage'];
            if (isset($extra_params['offset']))
                $this->offset = $extra_params['offset'];
            if ($this->page && $this->limit)
                $this->will_paginate = true;
                
            $this->complete_sql = [$sql, $params];
            return $this;
        } else
            return $this->complete_sql;
    }
451532
public function setupDatabaseTables()
    {
        $logger = $this->getLogger();
        $database = $this->getDatabase();

        $databaseHandle = $database->getDatabaseConnection();
        $tableDefinition = $database->getTableDefinition();

        $tables = array_keys($tableDefinition);
        foreach ($tables as $tableName) {
            $logger->writeln('<info>Table "' . $tableName . '"</info>');

            $statement = $databaseHandle->prepare('SHOW TABLES LIKE :table');
            $statement->bindParam(':table', $tableName, \PDO::PARAM_STR);
            $statement->execute();

            if ($statement->rowCount() == 1) {
                $logger->writeln('<info>=> Exists. Skip it</info>');
                continue;
            }

            // Table does not exists. Try to create it
            $createTableResult = $databaseHandle->query($tableDefinition[$tableName]);

            if ($createTableResult === false) {
                $databaseError = $databaseHandle->errorInfo();
                $message = 'Table "%s" could not be created. %s (%s)';
                $message = sprintf($message, $tableName, $databaseError[2], $databaseError[1]);
                throw new \Exception($message, 1398100879);

            } else {
                $logger->writeln('<info>Not exists. Created</info>');
            }
        }

        return true;
    }
946162
protected function deleteVisionFile($database, $tables)
    {
        foreach( $tables as $table )
        {
            unlink($this->getVisionFilePath($database, $table));
        }
    }
339647
public function addNewLangToDb()
    {
        //reset max count
        $this->_iCurrentMaxLangId = null;

        $table = $this->getAllTables();

        foreach ($table as $tableName) {
            $this->addNewMultilangField($tableName);
        }

        //updating views
        $this->updateViews();
    }
1227409
function tableExists(Connection $db, $table) {
    $q = $db->prepare("SHOW TABLES LIKE ?");
    $q->execute(array($table));

    if ($q->fetch()) {
      return true;
    } else {
      return false;
    }
  }
778122
public static function locateTemplate($template, $additionalPaths = array())
    {
        $defaultPaths = array(
            get_stylesheet_directory() . '/views',
            get_stylesheet_directory(),
            get_template_directory() . '/views',
            get_template_directory()
        );

        $searchPaths = array_merge($defaultPaths, $additionalPaths);

        $searchPaths = apply_filters('Municipio/blade/view_paths', $searchPaths);

        if (isset($searchPaths) && is_array($searchPaths) && !empty($searchPaths)) {
            foreach ($searchPaths as $path) {
                $file = $path . '/' . str_replace('.blade.php', '', basename($template)) . '.blade.php';

                if (!file_exists($file)) {
                    continue;
                }

                return $file;
            }
        } else {
            error_log("Muncipio error: No template search paths defined in " . __DIR__ . __FILE__);
        }

        return false;
    }
415316
protected function addTableToArchive($database, $table)
    {
        $this->createArchiveDatabaseDirectoryIfNotExists($database);

        file_put_contents
        (
            $this->getArchiveTableFilePath($path = $database . '/' . $table), 
            $this->getActiveTableFileContent($path)
        );
    }
162445
private function addNamespaces( $additionalNamespaces )
	{
		// Load any additional namespaces
		foreach ( $additionalNamespaces as $namespaces )
		{
			if ( is_null( $namespaces ) || ! is_array( $namespaces ) )
			{
				continue;
			}

			foreach ( $namespaces as $prefix => $namespace )
			{
				if ( empty( $prefix ) ) continue;
				$this->nsMgr->addNamespace( $prefix, $namespace );
			}
		}
	}
944547
public function db_select($database = '')
	{
		if ($database === '')
		{
			$database = $this->database;
		}

		if (mysql_select_db($database, $this->conn_id))
		{
			$this->database = $database;
			return TRUE;
		}

		return FALSE;
	}
1249196
public Map<String, Map<Long, FeatureShape>> getTables(String database) {

        Map<String, Map<Long, FeatureShape>> tables = databases.get(database);
        if (tables == null) {
            tables = new HashMap<>();
            databases.put(database, tables);
        }
        return tables;
    }