Convert a mysql table name to a class name, optionally removing a prefix.

@param $table
@param string $prefix

@return mixed
435282
public static function prettifyTableName($table, $prefix = '')
    {
        if ($prefix) {
            $table = self::removePrefix($table, $prefix);
        }

        return self::underscoresToCamelCase($table, true);
    }
351824
public function get_table( $table ) {
		if (
			! isset( $this->table_defines[ $table ] ) ||
			! empty( $this->table_defines[ $table ]['wordpress'] ) ||
			! empty( $this->table_defines[ $table ]['global'] )
		) {
			return $table;
		}

		return $this->get_table_prefix() . $table;
	}
460141
public function table($table) {
        $query = new Builder($this, $this->getQueryGrammar());

        return $query->from($table);
    }
1042754
public function dontRequireTable($table)
    {
        if (!isset($this->tableList[strtolower($table)])) {
            return;
        }
        $prefix = "_obsolete_{$table}";
        $suffix = '';
        $renameTo = $prefix . $suffix;
        while (isset($this->tableList[strtolower($renameTo)])) {
            $suffix = $suffix
                    ? ((int)$suffix + 1)
                    : 2;
            $renameTo = $prefix . $suffix;
        }
        $renameFrom = $this->tableList[strtolower($table)];
        $this->renameTable($renameFrom, $renameTo);
        $this->alterationMessage("Table $table: renamed to $renameTo", "obsolete");
    }
331949
protected static function getWithPrefix($table)
    {
        $prefix = static::$prefix;

        if (is_null($prefix) || empty($prefix)) {
            // If prefix is null, then no need to prepend a redundant _
            return $table;
        }

        return sprintf('%s_%s', $prefix, $table);
    }
678882
public function addPrefix($table) {
        if (strpos($table, '`') !== false) {
            return $table;
        }
        preg_match('/([\w_\.]+)( (as )?[\w_]+)?/i', $table, $match);
        $table = count($match) == 2 ? $table : $match[1];
        $alias = '';
        if (count($match) > 2) {
            $alias = $match[2];
        }
        if (strpos($table, '.') !== false) {
            list($schema, $table) = explode('.', $table);
            return sprintf('`%s`.`%s`%s', $schema, $table, $alias);
        }
        if (strpos($table, '!') === 0) {
            return sprintf('`%s`%s', substr($table, 1), $alias);
        }
        $prefix = $this->getEngine()->getConfig('prefix');
        if (empty($prefix)) {
            return sprintf('`%s`%s', $table, $alias);
        }
        return sprintf('`%s`%s', $prefix.
            Str::firstReplace($table, $prefix), $alias);
    }
595246
public function dropTable($table)
    {
        $table = $this->buildRealTableName($table);
        $sql = $this->getSchema()->getDropTableSql($table);
        $ret = $this->query($sql);
        return $ret;
    }
385756
public function table($table)
    {
        $this->table = $table;
        $alias = $this->alias ?? $this->table;

        if (!in_array('`' . $table . '`.*', $this->select) && !in_array('`' . $alias . '`.*', $this->select)) {
            $this->select[] = '`' . $table . '`.*';
        }

        return $this;
    }
1299997
private function getPrimaryKey(string $prefix, string $table): ?string
    {
        if (!$this->driver instanceof PostgresDriver) {
            throw new BuilderException('Postgres InsertQuery can be used only with Postgres driver and compiler');
        }

        return $this->driver->getPrimary($prefix, $table);
    }
12011
public function drop($table = '')
    {
        $tableName = '';

        $tableName = ($table !== '') ?
            $table : $this->tableName;

        $this->schema = strtoupper(__FUNCTION__).' TABLE IF EXISTS
        `'.$this->database.'`.`'.$tableName.'`'.PHP_EOL;

        return $this;
    }
1373563
public function table($table)
    {
        $processor = $this->getPostProcessor();

        $query = new MbDatabaseQueryBuilder($this, $this->getQueryGrammar(), $processor);

        return $query->from($table);
    }
28267
final public function traceTableAlias($table)
    {

        if (is_array($table)) {
            foreach ($table as $t) {
                $this->traceTableAlias($t);
            }
            return;
        }
        // Does the string contain a comma?  If so, we need to separate
        // the string into discreet statements
        if (strpos($table, ',') !== FALSE) {
            return $this->traceTableAlias(explode(',', $table));
        }
        // if a table alias is used we can recognize it by a space
        if (strpos($table, " ") !== FALSE) {
            // if the alias is written with the AS keyword, remove it
            $table = preg_replace('/ AS /i', ' ', $table);

            // Grab the alias
            $table = trim(strrchr($table, " "));

            // Store the alias, if it doesn't already exist
            if (!in_array($table, $this->arrayAliasedTables)) {
                $this->arrayAliasedTables[] = $table;
            }
        }
    }
588843
public function table($table)
    {
        $processor = $this->getPostProcessor();
        $grammar = $this->getQueryGrammar();

        $query = new CassandraBuilder($this, $grammar, $processor);

        return $query->from($table);
    }
465273
public static function showTables($prefix)
    {
        $results = static::select('SHOW FULL TABLES');

        $tables = [];
        $views = [];
        $first = '';
        foreach ($results as $result) {
            // get the first element (table name)
            foreach ($result as $value) {
                $first = $value;
                break;
            }

            // skip all tables that are not the current prefix
            if (!empty($prefix)) {
                if (!starts_with($first, $prefix)) {
                    continue;
                }
            }

            // separate views from tables
            if ($result->Table_type == 'VIEW') {
                $views[] = $first;
            } else {
                $tables[] = $first;
            }
        }

        return ['tables' => $tables, 'views' => $views];
    }
1132414
private function equalsKeys(Table $table, $prefix) {
        $thisKeys = $this->getKeys();
        $tableKeys = $table->getKeys();
        $errors = [];

        foreach($thisKeys as $key) {
            if(array_key_exists($key->getName(), $tableKeys)) {
                $errors = array_merge($errors, $key->equals($tableKeys[$key->getName()], $prefix));
            }
        }

        $thisKeyNames = array_keys($thisKeys);
        $tableKeyNames = array_keys($tableKeys);
        $diff = array_diff($tableKeyNames, $thisKeyNames);
        if(!empty($diff)) {
            $errors[] = $prefix . 'Extra Keys: ' . "\n" . implode("\n", $diff);
        }
        $diff = array_diff($thisKeyNames, $tableKeyNames);
        if(!empty($diff)) {
            $errors[] = $prefix . 'Missing Keys: ' . "\n" . implode("\n", $diff);
        }
        return $errors;
    }
475386
public function tableClass($table)
    {
        $tables = $this->getTableNames();
        $class = array_search($table, $tables, true);
        if ($class) {
            return $class;
        }

        // If there is no class for this table, strip table modifiers (e.g. _Live / _Versions)
        // from the end and re-attempt a search.
        if (preg_match('/^(?<class>.+)(_[^_]+)$/i', $table, $matches)) {
            $table = $matches['class'];
            $class = array_search($table, $tables, true);
            if ($class) {
                return $class;
            }
        }
        return null;
    }
620421
public function withColumnNamesPrefixedBy(string $prefix)
    {
        $clone                 = clone $this;
        $clone->table          = $clone->table->withColumnsPrefixedBy($prefix);
        $clone->orderColumn    = $clone->orderColumn->withPrefix($prefix);
        $clone->groupingColumn = $clone->groupingColumn
                ? $clone->groupingColumn->withPrefix($prefix)
                : null;

        return $clone;
    }