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
42d332f8
Commit
42d332f8
authored
Jun 09, 2013
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #517 from gevik/pgsql-small-fix
Pgsql small fix (update 2)
parents
c2b47d81
ec9dab11
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
11 deletions
+8
-11
Schema.php
framework/yii/db/pgsql/Schema.php
+8
-11
No files found.
framework/yii/db/pgsql/Schema.php
View file @
42d332f8
...
...
@@ -73,7 +73,7 @@ class Schema extends \yii\db\Schema
);
/**
* Creates a query builder for the
My
SQL database.
* Creates a query builder for the
Postgre
SQL database.
* @return QueryBuilder query builder instance
*/
public
function
createQueryBuilder
()
...
...
@@ -143,14 +143,9 @@ class Schema extends \yii\db\Schema
$sql
=
<<<SQL
select
ct.conname as containst,
c.relname as table_name,
ns.nspname as table_schema,
current_database() as table_catalog,
(select string_agg(attname,',') attname from pg_attribute where attrelid=ct.conrelid and attnum = any(ct.conkey)) as columns,
fc.relname as foreign_table_name,
fns.nspname as foreign_table_schema,
current_database() as foreign_table_catalog,
(select string_agg(attname,',') attname from pg_attribute where attrelid=ct.confrelid and attnum = any(ct.confkey)) as foreign_columns
from
pg_constraint ct
...
...
@@ -169,7 +164,12 @@ SQL;
foreach
(
$constraints
as
$constraint
)
{
$columns
=
explode
(
','
,
$constraint
[
'columns'
]);
$fcolumns
=
explode
(
','
,
$constraint
[
'foreign_columns'
]);
$citem
=
array
(
$constraint
[
'foreign_table_name'
]);
if
(
$constraint
[
'foreign_table_schema'
]
!==
$this
->
defaultSchema
)
{
$foreign_table
=
$constraint
[
'foreign_table_schema'
]
.
'.'
.
$constraint
[
'foreign_table_name'
];
}
else
{
$foreign_table
=
$constraint
[
'foreign_table_name'
];
}
$citem
=
array
(
$foreign_table
);
foreach
(
$columns
as
$idx
=>
$column
)
{
$citem
[]
=
array
(
$fcolumns
[
$idx
]
=>
$column
);
}
...
...
@@ -243,10 +243,6 @@ ORDER BY
SQL;
$columns
=
$this
->
db
->
createCommand
(
$sql
)
->
queryAll
();
if
(
empty
(
$columns
))
{
return
false
;
}
foreach
(
$columns
as
$column
)
{
$column
=
$this
->
loadColumnSchema
(
$column
);
$table
->
columns
[
$column
->
name
]
=
$column
;
...
...
@@ -289,4 +285,5 @@ SQL;
$column
->
phpType
=
$this
->
getColumnPhpType
(
$column
);
return
$column
;
}
}
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