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
c338d4b7
Commit
c338d4b7
authored
Jun 09, 2013
by
gevik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated code styling and added braces.
parent
f667b578
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
9 deletions
+13
-9
Command.php
framework/yii/db/Command.php
+2
-2
QueryBuilder.php
framework/yii/db/QueryBuilder.php
+8
-4
QueryBuilder.php
framework/yii/db/mysql/QueryBuilder.php
+1
-1
QueryBuilder.php
framework/yii/db/sqlite/QueryBuilder.php
+2
-2
No files found.
framework/yii/db/Command.php
View file @
c338d4b7
...
@@ -661,7 +661,7 @@ class Command extends \yii\base\Component
...
@@ -661,7 +661,7 @@ class Command extends \yii\base\Component
* @param string|array $columns comma separated string or array of columns that the primary key will consist of.
* @param string|array $columns comma separated string or array of columns that the primary key will consist of.
* @return Command the command object itself.
* @return Command the command object itself.
*/
*/
public
function
addPrimaryKey
(
$name
,
$table
,
$columns
)
public
function
addPrimaryKey
(
$name
,
$table
,
$columns
)
{
{
$sql
=
$this
->
db
->
getQueryBuilder
()
->
addPrimaryKey
(
$name
,
$table
,
$columns
);
$sql
=
$this
->
db
->
getQueryBuilder
()
->
addPrimaryKey
(
$name
,
$table
,
$columns
);
return
$this
->
setSql
(
$sql
);
return
$this
->
setSql
(
$sql
);
...
@@ -673,7 +673,7 @@ class Command extends \yii\base\Component
...
@@ -673,7 +673,7 @@ class Command extends \yii\base\Component
* @param string $table the table that the primary key constraint will be removed from.
* @param string $table the table that the primary key constraint will be removed from.
* @return Command the command object itself
* @return Command the command object itself
*/
*/
public
function
dropPrimarykey
(
$name
,
$table
)
public
function
dropPrimarykey
(
$name
,
$table
)
{
{
$sql
=
$this
->
db
->
getQueryBuilder
()
->
dropPrimarykey
(
$name
,
$table
);
$sql
=
$this
->
db
->
getQueryBuilder
()
->
dropPrimarykey
(
$name
,
$table
);
return
$this
->
setSql
(
$sql
);
return
$this
->
setSql
(
$sql
);
...
...
framework/yii/db/QueryBuilder.php
View file @
c338d4b7
...
@@ -276,12 +276,16 @@ class QueryBuilder extends \yii\base\Object
...
@@ -276,12 +276,16 @@ class QueryBuilder extends \yii\base\Object
* @param string|array $columns comma separated string or array of columns that the primary key will consist of.
* @param string|array $columns comma separated string or array of columns that the primary key will consist of.
* @return string the SQL statement for adding a primary key constraint to an existing table.
* @return string the SQL statement for adding a primary key constraint to an existing table.
*/
*/
public
function
addPrimaryKey
(
$name
,
$table
,
$columns
)
public
function
addPrimaryKey
(
$name
,
$table
,
$columns
)
{
{
if
(
is_string
(
$columns
))
if
(
is_string
(
$columns
))
{
$columns
=
preg_split
(
'/\s*,\s*/'
,
$columns
,
-
1
,
PREG_SPLIT_NO_EMPTY
);
$columns
=
preg_split
(
'/\s*,\s*/'
,
$columns
,
-
1
,
PREG_SPLIT_NO_EMPTY
);
foreach
(
$columns
as
$i
=>
$col
)
}
foreach
(
$columns
as
$i
=>
$col
)
{
$columns
[
$i
]
=
$this
->
db
->
quoteColumnName
(
$col
);
$columns
[
$i
]
=
$this
->
db
->
quoteColumnName
(
$col
);
}
return
'ALTER TABLE '
.
$this
->
db
->
quoteTableName
(
$table
)
.
' ADD CONSTRAINT '
return
'ALTER TABLE '
.
$this
->
db
->
quoteTableName
(
$table
)
.
' ADD CONSTRAINT '
.
$this
->
db
->
quoteColumnName
(
$name
)
.
' PRIMARY KEY ('
.
$this
->
db
->
quoteColumnName
(
$name
)
.
' PRIMARY KEY ('
.
implode
(
', '
,
$columns
)
.
' )'
;
.
implode
(
', '
,
$columns
)
.
' )'
;
...
@@ -293,7 +297,7 @@ class QueryBuilder extends \yii\base\Object
...
@@ -293,7 +297,7 @@ class QueryBuilder extends \yii\base\Object
* @param string $table the table that the primary key constraint will be removed from.
* @param string $table the table that the primary key constraint will be removed from.
* @return string the SQL statement for removing a primary key constraint from an existing table. *
* @return string the SQL statement for removing a primary key constraint from an existing table. *
*/
*/
public
function
dropPrimarykey
(
$name
,
$table
)
public
function
dropPrimarykey
(
$name
,
$table
)
{
{
return
'ALTER TABLE '
.
$this
->
db
->
quoteTableName
(
$table
)
return
'ALTER TABLE '
.
$this
->
db
->
quoteTableName
(
$table
)
.
' DROP CONSTRAINT '
.
$this
->
db
->
quoteColumnName
(
$name
);
.
' DROP CONSTRAINT '
.
$this
->
db
->
quoteColumnName
(
$name
);
...
...
framework/yii/db/mysql/QueryBuilder.php
View file @
c338d4b7
...
@@ -94,7 +94,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
...
@@ -94,7 +94,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
* @param string $table the table that the primary key constraint will be removed from.
* @param string $table the table that the primary key constraint will be removed from.
* @return string the SQL statement for removing a primary key constraint from an existing table. *
* @return string the SQL statement for removing a primary key constraint from an existing table. *
*/
*/
public
function
dropPrimarykey
(
$name
,
$table
)
public
function
dropPrimarykey
(
$name
,
$table
)
{
{
return
'ALTER TABLE '
.
$this
->
db
->
quoteTableName
(
$table
)
.
' DROP PRIMARY KEY'
;
return
'ALTER TABLE '
.
$this
->
db
->
quoteTableName
(
$table
)
.
' DROP PRIMARY KEY'
;
}
}
...
...
framework/yii/db/sqlite/QueryBuilder.php
View file @
c338d4b7
...
@@ -188,7 +188,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
...
@@ -188,7 +188,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
* @return string the SQL statement for adding a primary key constraint to an existing table.
* @return string the SQL statement for adding a primary key constraint to an existing table.
* @throws NotSupportedException this is not supported by SQLite
* @throws NotSupportedException this is not supported by SQLite
*/
*/
public
function
addPrimaryKey
(
$name
,
$table
,
$columns
)
public
function
addPrimaryKey
(
$name
,
$table
,
$columns
)
{
{
throw
new
NotSupportedException
(
__METHOD__
.
' is not supported by SQLite.'
);
throw
new
NotSupportedException
(
__METHOD__
.
' is not supported by SQLite.'
);
}
}
...
@@ -200,7 +200,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
...
@@ -200,7 +200,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
* @return string the SQL statement for removing a primary key constraint from an existing table.
* @return string the SQL statement for removing a primary key constraint from an existing table.
* @throws NotSupportedException this is not supported by SQLite *
* @throws NotSupportedException this is not supported by SQLite *
*/
*/
public
function
dropPrimarykey
(
$name
,
$table
)
public
function
dropPrimarykey
(
$name
,
$table
)
{
{
throw
new
NotSupportedException
(
__METHOD__
.
' is not supported by SQLite.'
);
throw
new
NotSupportedException
(
__METHOD__
.
' is not supported by SQLite.'
);
}
}
...
...
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