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
e67d0b3c
Commit
e67d0b3c
authored
Jul 11, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP
parent
2018503c
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
28 additions
and
17 deletions
+28
-17
Command.php
framework/db/Command.php
+2
-1
Connection.php
framework/db/Connection.php
+1
-2
Schema.php
framework/db/Schema.php
+1
-3
Schema.php
framework/db/cubrid/Schema.php
+7
-6
QueryBuilder.php
framework/db/mssql/QueryBuilder.php
+2
-2
QueryBuilder.php
framework/db/oci/QueryBuilder.php
+4
-0
Schema.php
framework/db/oci/Schema.php
+6
-1
QueryBuilder.php
framework/db/pgsql/QueryBuilder.php
+2
-2
QueryBuilder.php
framework/db/sqlite/QueryBuilder.php
+3
-0
No files found.
framework/db/Command.php
View file @
e67d0b3c
...
...
@@ -272,11 +272,12 @@ class Command extends \yii\base\Component
foreach
(
$values
as
$name
=>
$value
)
{
if
(
is_array
(
$value
))
{
$this
->
_pendingParams
[
$name
]
=
$value
;
$this
->
params
[
$name
]
=
$value
[
0
];
}
else
{
$type
=
$this
->
db
->
getSchema
()
->
getPdoType
(
$value
);
$this
->
_pendingParams
[
$name
]
=
[
$value
,
$type
];
$this
->
params
[
$name
]
=
$value
;
}
$this
->
params
[
$name
]
=
$value
;
}
return
$this
;
...
...
framework/db/Connection.php
View file @
e67d0b3c
...
...
@@ -643,8 +643,7 @@ class Connection extends Component
if
((
$pos
=
strpos
(
$this
->
dsn
,
':'
))
!==
false
)
{
$this
->
_driverName
=
strtolower
(
substr
(
$this
->
dsn
,
0
,
$pos
));
}
else
{
$this
->
open
();
$this
->
_driverName
=
strtolower
(
$this
->
pdo
->
getAttribute
(
PDO
::
ATTR_DRIVER_NAME
));
$this
->
_driverName
=
strtolower
(
$this
->
getReadPdo
()
->
getAttribute
(
PDO
::
ATTR_DRIVER_NAME
));
}
}
return
$this
->
_driverName
;
...
...
framework/db/Schema.php
View file @
e67d0b3c
...
...
@@ -369,9 +369,7 @@ abstract class Schema extends Object
return
$str
;
}
$pdo
=
$this
->
db
->
getReadPdo
();
if
((
$value
=
$pdo
->
quote
(
$str
))
!==
false
)
{
if
((
$value
=
$this
->
db
->
getReadPdo
()
->
quote
(
$str
))
!==
false
)
{
return
$value
;
}
else
{
// the driver doesn't support quote (e.g. oci)
...
...
framework/db/cubrid/Schema.php
View file @
e67d0b3c
...
...
@@ -143,8 +143,9 @@ class Schema extends \yii\db\Schema
*/
protected
function
loadTableSchema
(
$name
)
{
$this
->
db
->
open
();
$tableInfo
=
$this
->
db
->
pdo
->
cubrid_schema
(
\PDO
::
CUBRID_SCH_TABLE
,
$name
);
$pdo
=
$this
->
db
->
getReadPdo
();
$tableInfo
=
$pdo
->
cubrid_schema
(
\PDO
::
CUBRID_SCH_TABLE
,
$name
);
if
(
!
isset
(
$tableInfo
[
0
][
'NAME'
]))
{
return
null
;
...
...
@@ -161,7 +162,7 @@ class Schema extends \yii\db\Schema
$table
->
columns
[
$column
->
name
]
=
$column
;
}
$primaryKeys
=
$
this
->
db
->
pdo
->
cubrid_schema
(
\PDO
::
CUBRID_SCH_PRIMARY_KEY
,
$table
->
name
);
$primaryKeys
=
$pdo
->
cubrid_schema
(
\PDO
::
CUBRID_SCH_PRIMARY_KEY
,
$table
->
name
);
foreach
(
$primaryKeys
as
$key
)
{
$column
=
$table
->
columns
[
$key
[
'ATTR_NAME'
]];
$column
->
isPrimaryKey
=
true
;
...
...
@@ -171,7 +172,7 @@ class Schema extends \yii\db\Schema
}
}
$foreignKeys
=
$
this
->
db
->
pdo
->
cubrid_schema
(
\PDO
::
CUBRID_SCH_IMPORTED_KEYS
,
$table
->
name
);
$foreignKeys
=
$pdo
->
cubrid_schema
(
\PDO
::
CUBRID_SCH_IMPORTED_KEYS
,
$table
->
name
);
foreach
(
$foreignKeys
as
$key
)
{
if
(
isset
(
$table
->
foreignKeys
[
$key
[
'FK_NAME'
]]))
{
$table
->
foreignKeys
[
$key
[
'FK_NAME'
]][
$key
[
'FKCOLUMN_NAME'
]]
=
$key
[
'PKCOLUMN_NAME'
];
...
...
@@ -265,8 +266,8 @@ class Schema extends \yii\db\Schema
*/
protected
function
findTableNames
(
$schema
=
''
)
{
$
this
->
db
->
open
();
$tables
=
$this
->
db
->
pdo
->
cubrid_schema
(
\PDO
::
CUBRID_SCH_TABLE
);
$
pdo
=
$this
->
db
->
getReadPdo
();
$tables
=
$
pdo
->
cubrid_schema
(
\PDO
::
CUBRID_SCH_TABLE
);
$tableNames
=
[];
foreach
(
$tables
as
$table
)
{
// do not list system tables
...
...
framework/db/mssql/QueryBuilder.php
View file @
e67d0b3c
...
...
@@ -239,8 +239,8 @@ class QueryBuilder extends \yii\db\QueryBuilder
*/
protected
function
isOldMssql
()
{
$
this
->
db
->
open
();
$version
=
preg_split
(
"/\./"
,
$
this
->
db
->
pdo
->
getAttribute
(
\PDO
::
ATTR_SERVER_VERSION
));
$
pdo
=
$this
->
db
->
getReadPdo
();
$version
=
preg_split
(
"/\./"
,
$pdo
->
getAttribute
(
\PDO
::
ATTR_SERVER_VERSION
));
return
$version
[
0
]
<
11
;
}
}
framework/db/oci/QueryBuilder.php
View file @
e67d0b3c
...
...
@@ -132,7 +132,11 @@ EOD;
if
(
$value
!==
null
)
{
$value
=
(
int
)
$value
;
}
else
{
// use master connection to get the biggest PK value
$enableSlave
=
$this
->
db
->
enableSlave
;
$this
->
db
->
enableSlave
=
false
;
$value
=
(
int
)
$this
->
db
->
createCommand
(
"SELECT MAX(
\"
{
$tableSchema
->
primaryKey
}
\"
) FROM
\"
{
$tableSchema
->
name
}
\"
"
)
->
queryScalar
();
$this
->
db
->
enableSlave
=
$enableSlave
;
$value
++
;
}
...
...
framework/db/oci/Schema.php
View file @
e67d0b3c
...
...
@@ -195,7 +195,12 @@ EOD;
public
function
getLastInsertID
(
$sequenceName
=
''
)
{
if
(
$this
->
db
->
isActive
)
{
return
$this
->
db
->
createCommand
(
"SELECT
{
$sequenceName
}
.CURRVAL FROM DUAL"
)
->
queryScalar
();
// get the last insert id from the master connection
$enableSlave
=
$this
->
db
->
enableSlave
;
$this
->
db
->
enableSlave
=
false
;
$id
=
$this
->
db
->
createCommand
(
"SELECT
{
$sequenceName
}
.CURRVAL FROM DUAL"
)
->
queryScalar
();
$this
->
db
->
enableSlave
=
$enableSlave
;
return
$id
;
}
else
{
throw
new
InvalidCallException
(
'DB Connection is not active.'
);
}
...
...
framework/db/pgsql/QueryBuilder.php
View file @
e67d0b3c
...
...
@@ -136,8 +136,8 @@ class QueryBuilder extends \yii\db\QueryBuilder
$command
.=
"ALTER TABLE
$tableName
$enable
TRIGGER ALL; "
;
}
#
enable to have ability to alter several tables
$this
->
db
->
pdo
->
setAttribute
(
\PDO
::
ATTR_EMULATE_PREPARES
,
true
);
//
enable to have ability to alter several tables
$this
->
db
->
getWritePdo
()
->
setAttribute
(
\PDO
::
ATTR_EMULATE_PREPARES
,
true
);
return
$command
;
}
...
...
framework/db/sqlite/QueryBuilder.php
View file @
e67d0b3c
...
...
@@ -120,7 +120,10 @@ class QueryBuilder extends \yii\db\QueryBuilder
if
(
$value
===
null
)
{
$key
=
reset
(
$table
->
primaryKey
);
$tableName
=
$db
->
quoteTableName
(
$tableName
);
$enableSlave
=
$this
->
db
->
enableSlave
;
$this
->
db
->
enableSlave
=
false
;
$value
=
$db
->
createCommand
(
"SELECT MAX('
$key
') FROM
$tableName
"
)
->
queryScalar
();
$this
->
db
->
enableSlave
=
$enableSlave
;
}
else
{
$value
=
(
int
)
$value
-
1
;
}
...
...
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