Prado\Data\Common\Mssql\TMssqlMetaData::findTableNames PHP 메소드

findTableNames() 공개 메소드

Returns all table names in the database.
public findTableNames ( string $schema = 'dbo' ) : array
$schema string the schema of the tables. Defaults to empty string, meaning the current or default schema. If not empty, the returned table names will be prefixed with the schema name.
리턴 array all table names in the database.
    public function findTableNames($schema = 'dbo')
    {
        $condition = "TABLE_TYPE='BASE TABLE'";
        $sql = <<<EOD
SELECT TABLE_NAME, TABLE_SCHEMA FROM [INFORMATION_SCHEMA].[TABLES]
WHERE TABLE_SCHEMA=:schema AND {$condition}
EOD;
        $command = $this->getDbConnection()->createCommand($sql);
        $command->bindParam(":schema", $schema);
        $rows = $command->queryAll();
        $names = array();
        foreach ($rows as $row) {
            if ($schema == self::DEFAULT_SCHEMA) {
                $names[] = $row['TABLE_NAME'];
            } else {
                $names[] = $schema . '.' . $row['TABLE_SCHEMA'] . '.' . $row['TABLE_NAME'];
            }
        }
        return $names;
    }