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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
cf1e12ad
Commit
cf1e12ad
authored
Jun 08, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes issue #514.
parent
51972f25
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
10 deletions
+18
-10
Schema.php
framework/yii/db/pgsql/Schema.php
+18
-10
No files found.
framework/yii/db/pgsql/Schema.php
View file @
cf1e12ad
...
...
@@ -76,7 +76,8 @@ class Schema extends \yii\db\Schema
* Creates a query builder for the MySQL database.
* @return QueryBuilder query builder instance
*/
public
function
createQueryBuilder
()
{
public
function
createQueryBuilder
()
{
return
new
QueryBuilder
(
$this
->
db
);
}
...
...
@@ -85,7 +86,8 @@ class Schema extends \yii\db\Schema
* @param TableSchema $table the table metadata object
* @param string $name the table name
*/
protected
function
resolveTableNames
(
$table
,
$name
)
{
protected
function
resolveTableNames
(
$table
,
$name
)
{
$parts
=
explode
(
'.'
,
str_replace
(
'"'
,
''
,
$name
));
if
(
isset
(
$parts
[
1
]))
{
$table
->
schemaName
=
$parts
[
0
];
...
...
@@ -104,7 +106,8 @@ class Schema extends \yii\db\Schema
* @param string $name table name
* @return string the properly quoted table name
*/
public
function
quoteSimpleTableName
(
$name
)
{
public
function
quoteSimpleTableName
(
$name
)
{
return
strpos
(
$name
,
'"'
)
!==
false
?
$name
:
'"'
.
$name
.
'"'
;
}
...
...
@@ -113,12 +116,15 @@ class Schema extends \yii\db\Schema
* @param string $name table name
* @return TableSchema|null driver dependent table metadata. Null if the table does not exist.
*/
public
function
loadTableSchema
(
$name
)
{
public
function
loadTableSchema
(
$name
)
{
$table
=
new
TableSchema
();
$this
->
resolveTableNames
(
$table
,
$name
);
if
(
$this
->
findColumns
(
$table
))
{
$this
->
findConstraints
(
$table
);
return
$table
;
}
else
{
return
null
;
}
}
...
...
@@ -126,7 +132,8 @@ class Schema extends \yii\db\Schema
* Collects the foreign key column details for the given table.
* @param TableSchema $table the table metadata
*/
protected
function
findConstraints
(
$table
)
{
protected
function
findConstraints
(
$table
)
{
$tableName
=
$this
->
quoteValue
(
$table
->
name
);
$tableSchema
=
$this
->
quoteValue
(
$table
->
schemaName
);
...
...
@@ -175,7 +182,8 @@ SQL;
* @param TableSchema $table the table metadata
* @return boolean whether the table exists in the database
*/
protected
function
findColumns
(
$table
)
{
protected
function
findColumns
(
$table
)
{
$tableName
=
$this
->
db
->
quoteValue
(
$table
->
name
);
$schemaName
=
$this
->
db
->
quoteValue
(
$table
->
schemaName
);
$sql
=
<<<SQL
...
...
@@ -234,11 +242,11 @@ ORDER BY
a.attnum;
SQL;
try
{
$columns
=
$this
->
db
->
createCommand
(
$sql
)
->
queryAll
();
}
catch
(
\Exception
$e
)
{
if
(
empty
(
$columns
)
)
{
return
false
;
}
foreach
(
$columns
as
$column
)
{
$column
=
$this
->
loadColumnSchema
(
$column
);
$table
->
columns
[
$column
->
name
]
=
$column
;
...
...
@@ -257,7 +265,8 @@ SQL;
* @param array $info column information
* @return ColumnSchema the column schema object
*/
protected
function
loadColumnSchema
(
$info
)
{
protected
function
loadColumnSchema
(
$info
)
{
$column
=
new
ColumnSchema
();
$column
->
allowNull
=
$info
[
'is_nullable'
];
$column
->
autoIncrement
=
$info
[
'is_autoinc'
];
...
...
@@ -280,5 +289,4 @@ 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