Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
b6f07859
Commit
b6f07859
authored
Sep 08, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for getting all tables for pgsql.
parent
e683bd3d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
0 deletions
+29
-0
Schema.php
framework/yii/db/pgsql/Schema.php
+29
-0
No files found.
framework/yii/db/pgsql/Schema.php
View file @
b6f07859
...
@@ -129,6 +129,35 @@ class Schema extends \yii\db\Schema
...
@@ -129,6 +129,35 @@ class Schema extends \yii\db\Schema
}
}
/**
/**
* Returns all table names in the database.
* @param string $schema 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.
* @return array all table names in the database.
*/
protected
function
findTableNames
(
$schema
=
''
)
{
if
(
$schema
===
''
)
{
$schema
=
$this
->
defaultSchema
;
}
$sql
=
<<<EOD
SELECT table_name, table_schema FROM information_schema.tables
WHERE table_schema=:schema AND table_type='BASE TABLE'
EOD;
$command
=
$this
->
db
->
createCommand
(
$sql
);
$command
->
bindParam
(
':schema'
,
$schema
);
$rows
=
$command
->
queryAll
();
$names
=
array
();
foreach
(
$rows
as
$row
)
{
if
(
$schema
===
$this
->
defaultSchema
)
{
$names
[]
=
$row
[
'table_name'
];
}
else
{
$names
[]
=
$row
[
'table_schema'
]
.
'.'
.
$row
[
'table_name'
];
}
}
return
$names
;
}
/**
* Collects the foreign key column details for the given table.
* Collects the foreign key column details for the given table.
* @param TableSchema $table the table metadata
* @param TableSchema $table the table metadata
*/
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment