yii\db\pgsql\Schema::findViewNames PHP Method

findViewNames() protected method

Returns all views names in the database.
Since: 2.0.9
protected findViewNames ( string $schema = '' ) : array
$schema string the schema of the views. Defaults to empty string, meaning the current or default schema.
return array all views names in the database. The names have NO schema name prefix.
    protected function findViewNames($schema = '')
    {
        if ($schema === '') {
            $schema = $this->defaultSchema;
        }
        $sql = <<<SQL
SELECT c.relname AS table_name
FROM pg_class c
INNER JOIN pg_namespace ns ON ns.oid = c.relnamespace
WHERE ns.nspname = :schemaName AND c.relkind = 'v'
ORDER BY c.relname
SQL;
        $command = $this->db->createCommand($sql, [':schemaName' => $schema]);
        $rows = $command->queryAll();
        $names = [];
        foreach ($rows as $row) {
            $names[] = $row['table_name'];
        }
        return $names;
    }