Adds database (if needed) and tablename prefix to the table name

@param return $tableName
@param boolean $addDatabaseName Optional, when true (= default) and there is a database name then it is prepended to the name.
@return string
502077
protected function addDatabasePrefix($tableName, $addDatabaseName = true)
    {
        return ($addDatabaseName && $this->_sourceData['gso_ls_database'] ? $this->_sourceData['gso_ls_database'] . '.' : '') .
            $this->_sourceData['gso_ls_table_prefix'] .
            $tableName;
    }
818279
public function setDbName($dbName = null)
    {
        $this->dbName = ($dbName === null ? Propel::getDefaultDB() : $dbName);
    }
977552
public function generateTableName($tableName)
    {
        if (!$this->useTablePrefix) {
            return $tableName;
        }

        $db = $this->getDbConnection();
        if (preg_match("/^{$db->tablePrefix}(.*?)$/", $tableName, $matches)) {
            $tableName = '{{%' . $matches[1] . '}}';
        } elseif (preg_match("/^(.*?){$db->tablePrefix}$/", $tableName, $matches)) {
            $tableName = '{{' . $matches[1] . '%}}';
        }
        return $tableName;
    }
1280385
public String fixDatabaseProductName(String strDatabaseProductName)
    {
    	if (strDatabaseProductName == null)
    		return null;
    	if (strDatabaseProductName.lastIndexOf(' ') != -1)
    		strDatabaseProductName = strDatabaseProductName.substring(strDatabaseProductName.lastIndexOf(' ') + 1);
    	return strDatabaseProductName.toLowerCase();
    }
921903
public static String getDatabaseName() {
        String databaseName = getMetaDataString(METADATA_DATABASE);

        if (databaseName == null) {
            databaseName = DATABASE_DEFAULT_NAME;
        }

        return databaseName;
    }
191123
public function getDatabase($connectionName = 'default')
    {
        if ($this->databases->containsKey($connectionName)) {
            return $this->databases->get($connectionName);
        }

        $configuration = $this->getConfiguration($connectionName);
        $database = $this->getConnection($connectionName);

        $database->DBOpen(
            $configuration->getDatabase(),
            $configuration->getUser(),
            $configuration->getPassword()
        );

        $this->databases->set($connectionName, $database);

        return $this->databases->get($connectionName);
    }
211991
protected function generateClassName($tableName)
    {
        if (isset($this->_classNames[$tableName])) {
            return $this->_classNames[$tableName];
        }

        if (($pos = strrpos($tableName, '.')) !== false) {
            $tableName = substr($tableName, $pos + 1);
        }

        $db = $this->getDbConnection();
        $patterns = [];
        $patterns[] = "/^{$db->tablePrefix}(.*?)$/";
        $patterns[] = "/^(.*?){$db->tablePrefix}$/";
        if (strpos($this->tableName, '*') !== false) {
            $pattern = $this->tableName;
            if (($pos = strrpos($pattern, '.')) !== false) {
                $pattern = substr($pattern, $pos + 1);
            }
            $patterns[] = '/^' . str_replace('*', '(\w+)', $pattern) . '$/';
        }
        $className = $tableName;
        foreach ($patterns as $pattern) {
            if (preg_match($pattern, $tableName, $matches)) {
                $className = $matches[1];
                break;
            }
        }

        return $this->_classNames[$tableName] = Inflector::id2camel($className, '_');
    }
113313
public function getDatabaseName()
    {
        if (isset($this->_data['filter_column']) && is_string($this->_data['filter_column'])) {
            return $this->_data['filter_column'];
        }
        return $this->index();
    }
981940
public function getTables($dbName = '')
    {
        $pdo    = $this->linkID->query("select table_name from all_tables");
        $result = $pdo->fetchAll(PDO::FETCH_ASSOC);
        $info   = [];
        foreach ($result as $key => $val) {
            $info[$key] = current($val);
        }
        return $info;
    }
580878
public function insert($tableName)
    {
        $sql = new Insert($tableName);
        $sql->setAdapter($this->_adapter);
        return $sql;
    }
824295
public function table($tableName)
    {
        return new Table(
            $this->dbManager,
            $this->connectionName,
            $tableName,
            $this->getStructure($this->connectionName)
        );
    }
785144
public function add(Array $addData)
    {
        $addFields = array();
        $addValues = array();
        foreach ($addData as $key => $value) {
            $addFields[] = $key;
            $addValues[] = '\'' . $value . '\'';
        }
        $fields = implode(',', $addFields);
        $values = implode(',', $addValues);
        $this->sql = "INSERT INTO {$this->_table} ($fields)VALUES($values)";
        return $this->execute()->rowCount();
    }
50454
private function getAddedIndexes($tableName, TableDiff $diff)
    {
        /** @var $index \Doctrine\DBAL\Schema\Index */
        foreach ($diff->addedIndexes as $index) {
            $this->addMessage($tableName, sprintf('missing index on `%s`', implode(', ', $index->getUnquotedColumns())));
        }
    }
1220528
public function tableName($tableName = null)
    {
        if ($tableName === null)
        {
            return $this->_tableName;
        }
        $this->_tableName = $tableName;

        return $this;
    }
692454
public function rename($newName, $returnNew = true)
    {
        // Mysql 5.1.7 do not have RENAME DATABASE syntax anymore, so we use rename tables to do that.
        // @see: http://stackoverflow.com/questions/67093/how-do-i-quickly-rename-a-mysql-database-change-schema-name?page=1&tab=votes#tab-top
        $newDatabase = $this->db->getDatabase($newName)->create();

        $tables = $this->db->getReader(MysqlGrammar::showDbTables($this->name))->loadObjectList();

        foreach ($tables as $table) {
            $name = $table->Name;

            $this->db->setQuery(
                sprintf(
                    'RENAME TABLE %s.%s TO %s.%s',
                    $this->db->quoteName($this->name),
                    $this->db->quoteName($name),
                    $this->db->quoteName($newName),
                    $this->db->quoteName($name)
                )
            )->execute();
        }

        $this->drop(true);

        if ($returnNew) {
            return $newDatabase;
        }

        return $this;
    }
928046
public function getTableByPhpName($phpName)
    {
        if ('\\' !== $phpName[0]) {
            $phpName = '\\' . $phpName;
        }
        if (isset($this->tablesByPhpName[$phpName])) {
            return $this->tablesByPhpName[$phpName];
        }

        if (class_exists($tmClass = $phpName . 'TableMap')) {
            $this->addTableFromMapClass($tmClass);

            return $this->tablesByPhpName[$phpName];
        }

        if (class_exists($tmClass = substr_replace($phpName, '\\Map\\', strrpos($phpName, '\\'), 1) . 'TableMap')
            || class_exists($tmClass = '\\Map\\' .$phpName . 'TableMap')) {
            $this->addTableFromMapClass($tmClass);

            if (isset($this->tablesByPhpName[$phpName])) {
                return $this->tablesByPhpName[$phpName];
            }

            if (isset($this->tablesByPhpName[$phpName])) {
                return $this->tablesByPhpName[$phpName];
            }
        }

        throw new TableNotFoundException(sprintf('Cannot fetch TableMap for undefined table phpName: %s.', $phpName));
    }
7050
public function addCode($tableName, $columnName = 'code')
    {
        $this->addColumn('{{%' . $tableName . '}}', $columnName,
            $this->string(32)->comment('Code for this item, used identifying when needed. Another criteria to replace ID because ID is auto-increment'));
        $this->createIndex($tableName . '_' . $columnName . '_idx', '{{%' . $tableName . '}}', $columnName);
    }