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
b700f712
Commit
b700f712
authored
Nov 05, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes #1142: exposes Command::params.
parent
94c0b278
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
10 deletions
+12
-10
Command.php
framework/yii/db/Command.php
+12
-10
No files found.
framework/yii/db/Command.php
View file @
b700f712
...
@@ -67,13 +67,15 @@ class Command extends \yii\base\Component
...
@@ -67,13 +67,15 @@ class Command extends \yii\base\Component
*/
*/
public
$fetchMode
=
\PDO
::
FETCH_ASSOC
;
public
$fetchMode
=
\PDO
::
FETCH_ASSOC
;
/**
/**
* @var string the SQL statement that this command represents
* @var array the parameters (name => value) that are bound to the current PDO statement.
* This property is maintained by methods such as [[bindValue()]].
* Do not modify it directly.
*/
*/
p
rivate
$_sql
;
p
ublic
$params
=
[]
;
/**
/**
* @var
array the parameter log information (name => value)
* @var
string the SQL statement that this command represents
*/
*/
private
$_
params
=
[]
;
private
$_
sql
;
/**
/**
* Returns the SQL statement for this command.
* Returns the SQL statement for this command.
...
@@ -95,7 +97,7 @@ class Command extends \yii\base\Component
...
@@ -95,7 +97,7 @@ class Command extends \yii\base\Component
if
(
$sql
!==
$this
->
_sql
)
{
if
(
$sql
!==
$this
->
_sql
)
{
$this
->
cancel
();
$this
->
cancel
();
$this
->
_sql
=
$this
->
db
->
quoteSql
(
$sql
);
$this
->
_sql
=
$this
->
db
->
quoteSql
(
$sql
);
$this
->
_
params
=
[];
$this
->
params
=
[];
}
}
return
$this
;
return
$this
;
}
}
...
@@ -108,11 +110,11 @@ class Command extends \yii\base\Component
...
@@ -108,11 +110,11 @@ class Command extends \yii\base\Component
*/
*/
public
function
getRawSql
()
public
function
getRawSql
()
{
{
if
(
empty
(
$this
->
_
params
))
{
if
(
empty
(
$this
->
params
))
{
return
$this
->
_sql
;
return
$this
->
_sql
;
}
else
{
}
else
{
$params
=
[];
$params
=
[];
foreach
(
$this
->
_
params
as
$name
=>
$value
)
{
foreach
(
$this
->
params
as
$name
=>
$value
)
{
if
(
is_string
(
$value
))
{
if
(
is_string
(
$value
))
{
$params
[
$name
]
=
$this
->
db
->
quoteValue
(
$value
);
$params
[
$name
]
=
$this
->
db
->
quoteValue
(
$value
);
}
elseif
(
$value
===
null
)
{
}
elseif
(
$value
===
null
)
{
...
@@ -190,7 +192,7 @@ class Command extends \yii\base\Component
...
@@ -190,7 +192,7 @@ class Command extends \yii\base\Component
}
else
{
}
else
{
$this
->
pdoStatement
->
bindParam
(
$name
,
$value
,
$dataType
,
$length
,
$driverOptions
);
$this
->
pdoStatement
->
bindParam
(
$name
,
$value
,
$dataType
,
$length
,
$driverOptions
);
}
}
$this
->
_
params
[
$name
]
=&
$value
;
$this
->
params
[
$name
]
=&
$value
;
return
$this
;
return
$this
;
}
}
...
@@ -212,7 +214,7 @@ class Command extends \yii\base\Component
...
@@ -212,7 +214,7 @@ class Command extends \yii\base\Component
$dataType
=
$this
->
db
->
getSchema
()
->
getPdoType
(
$value
);
$dataType
=
$this
->
db
->
getSchema
()
->
getPdoType
(
$value
);
}
}
$this
->
pdoStatement
->
bindValue
(
$name
,
$value
,
$dataType
);
$this
->
pdoStatement
->
bindValue
(
$name
,
$value
,
$dataType
);
$this
->
_
params
[
$name
]
=
$value
;
$this
->
params
[
$name
]
=
$value
;
return
$this
;
return
$this
;
}
}
...
@@ -239,7 +241,7 @@ class Command extends \yii\base\Component
...
@@ -239,7 +241,7 @@ class Command extends \yii\base\Component
$type
=
$this
->
db
->
getSchema
()
->
getPdoType
(
$value
);
$type
=
$this
->
db
->
getSchema
()
->
getPdoType
(
$value
);
}
}
$this
->
pdoStatement
->
bindValue
(
$name
,
$value
,
$type
);
$this
->
pdoStatement
->
bindValue
(
$name
,
$value
,
$type
);
$this
->
_
params
[
$name
]
=
$value
;
$this
->
params
[
$name
]
=
$value
;
}
}
}
}
return
$this
;
return
$this
;
...
...
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