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
c63c7838
Commit
c63c7838
authored
Dec 26, 2011
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
730dc3db
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
54 additions
and
44 deletions
+54
-44
YiiBase.php
framework/YiiBase.php
+1
-1
Application.php
framework/base/Application.php
+1
-1
ApplicationComponent.php
framework/base/ApplicationComponent.php
+1
-1
Object.php
framework/base/Object.php
+1
-1
Migration.php
framework/db/Migration.php
+1
-1
ActiveRecord.php
framework/db/ar/ActiveRecord.php
+1
-1
ColumnSchema.php
framework/db/dao/ColumnSchema.php
+4
-3
Command.php
framework/db/dao/Command.php
+0
-0
Query.php
framework/db/dao/Query.php
+0
-0
QueryBuilder.php
framework/db/dao/QueryBuilder.php
+18
-2
Schema.php
framework/db/dao/Schema.php
+2
-2
DbTarget.php
framework/logging/DbTarget.php
+1
-1
FileTarget.php
framework/logging/FileTarget.php
+1
-1
ProfileTarget.php
framework/logging/ProfileTarget.php
+1
-1
Router.php
framework/logging/Router.php
+2
-2
Target.php
framework/logging/Target.php
+2
-2
WebTarget.php
framework/logging/WebTarget.php
+1
-1
CaptchaValidator.php
framework/validators/CaptchaValidator.php
+2
-2
StringValidator.php
framework/validators/StringValidator.php
+1
-1
CommandTest.php
tests/unit/framework/db/dao/CommandTest.php
+13
-20
No files found.
framework/YiiBase.php
View file @
c63c7838
...
@@ -64,7 +64,7 @@ class YiiBase
...
@@ -64,7 +64,7 @@ class YiiBase
/**
/**
* @var yii\base\Application the application instance
* @var yii\base\Application the application instance
*/
*/
public
static
$app
;
public
static
$app
lication
;
/**
/**
* @var array registered path aliases
* @var array registered path aliases
* @see getAlias
* @see getAlias
...
...
framework/base/Application.php
View file @
c63c7838
...
@@ -116,7 +116,7 @@ abstract class Application extends Module
...
@@ -116,7 +116,7 @@ abstract class Application extends Module
*/
*/
public
function
__construct
(
$config
=
null
)
public
function
__construct
(
$config
=
null
)
{
{
\Yii
::
$app
=
$this
;
\Yii
::
$app
lication
=
$this
;
// set basePath at early as possible to avoid trouble
// set basePath at early as possible to avoid trouble
if
(
is_string
(
$config
))
{
if
(
is_string
(
$config
))
{
...
...
framework/base/ApplicationComponent.php
View file @
c63c7838
...
@@ -30,7 +30,7 @@ abstract class ApplicationComponent extends Component implements Initable
...
@@ -30,7 +30,7 @@ abstract class ApplicationComponent extends Component implements Initable
/**
/**
* Initializes the application component.
* Initializes the application component.
* This method is invoked after the component is created and its property values are
* This method is invoked after the component is created and its property values are
* initialized. The default implementation will call [[Component::attachBehaviors]]
* initialized. The default implementation will call [[Component::attachBehaviors
()
]]
* to attach behaviors declared in [[behaviors]].
* to attach behaviors declared in [[behaviors]].
* If you override this method, make sure to call the parent implementation.
* If you override this method, make sure to call the parent implementation.
*/
*/
...
...
framework/base/Object.php
View file @
c63c7838
...
@@ -294,7 +294,7 @@ class Object
...
@@ -294,7 +294,7 @@ class Object
* $model->init();
* $model->init();
* ~~~
* ~~~
*
*
* @return
o
bject the created object
* @return
O
bject the created object
* @throws Exception if the configuration is invalid.
* @throws Exception if the configuration is invalid.
*/
*/
public
static
function
newInstance
()
public
static
function
newInstance
()
...
...
framework/db/Migration.php
View file @
c63c7838
...
@@ -120,7 +120,7 @@ abstract class CDbMigration extends yii\base\Component
...
@@ -120,7 +120,7 @@ abstract class CDbMigration extends yii\base\Component
public
function
getDbConnection
()
public
function
getDbConnection
()
{
{
if
(
$this
->
_db
===
null
)
{
if
(
$this
->
_db
===
null
)
{
$this
->
_db
=
Yii
::
app
()
->
getComponent
(
'db'
);
$this
->
_db
=
\Yii
::
$application
->
getComponent
(
'db'
);
if
(
!
$this
->
_db
instanceof
CDbConnection
)
if
(
!
$this
->
_db
instanceof
CDbConnection
)
throw
new
CException
(
Yii
::
t
(
'yii'
,
'The "db" application component must be configured to be a CDbConnection object.'
));
throw
new
CException
(
Yii
::
t
(
'yii'
,
'The "db" application component must be configured to be a CDbConnection object.'
));
}
}
...
...
framework/db/ar/ActiveRecord.php
View file @
c63c7838
...
@@ -611,7 +611,7 @@ abstract class ActiveRecord extends \yii\base\Model
...
@@ -611,7 +611,7 @@ abstract class ActiveRecord extends \yii\base\Model
return
self
::
$db
;
return
self
::
$db
;
else
else
{
{
self
::
$db
=
Yii
::
app
()
->
getDb
();
self
::
$db
=
\Yii
::
$application
->
getDb
();
if
(
self
::
$db
instanceof
CDbConnection
)
if
(
self
::
$db
instanceof
CDbConnection
)
return
self
::
$db
;
return
self
::
$db
;
else
else
...
...
framework/db/dao/ColumnSchema.php
View file @
c63c7838
...
@@ -23,7 +23,7 @@ class ColumnSchema extends \yii\base\Component
...
@@ -23,7 +23,7 @@ class ColumnSchema extends \yii\base\Component
*/
*/
public
$name
;
public
$name
;
/**
/**
* @var string raw name of this column. This is the quoted name that can be used in SQL queries.
* @var string raw name of this column. This is the quoted name that can be
directly
used in SQL queries.
*/
*/
public
$quotedName
;
public
$quotedName
;
/**
/**
...
@@ -32,7 +32,8 @@ class ColumnSchema extends \yii\base\Component
...
@@ -32,7 +32,8 @@ class ColumnSchema extends \yii\base\Component
public
$allowNull
;
public
$allowNull
;
/**
/**
* @var string logical type of this column. Possible logic types include:
* @var string logical type of this column. Possible logic types include:
* string, text, boolean, smallint, integer, bigint, float, decimal, datetime, timestamp, time, date, binary, money
* string, text, boolean, smallint, integer, bigint, float, decimal, datetime,
* timestamp, time, date, binary, and money.
*/
*/
public
$type
;
public
$type
;
/**
/**
...
@@ -41,7 +42,7 @@ class ColumnSchema extends \yii\base\Component
...
@@ -41,7 +42,7 @@ class ColumnSchema extends \yii\base\Component
*/
*/
public
$phpType
;
public
$phpType
;
/**
/**
* @var string the DB type of this column.
* @var string the DB type of this column.
Possible DB types vary according to the DBMS.
*/
*/
public
$dbType
;
public
$dbType
;
/**
/**
...
...
framework/db/dao/Command.php
View file @
c63c7838
This diff is collapsed.
Click to expand it.
framework/db/dao/Query.php
View file @
c63c7838
This diff is collapsed.
Click to expand it.
framework/db/dao/QueryBuilder.php
View file @
c63c7838
...
@@ -40,6 +40,10 @@ class QueryBuilder extends \yii\base\Object
...
@@ -40,6 +40,10 @@ class QueryBuilder extends \yii\base\Object
$this
->
schema
=
$schema
;
$this
->
schema
=
$schema
;
}
}
/**
* @param Query $query
* @return string
*/
public
function
build
(
$query
)
public
function
build
(
$query
)
{
{
$clauses
=
array
(
$clauses
=
array
(
...
@@ -126,7 +130,6 @@ class QueryBuilder extends \yii\base\Object
...
@@ -126,7 +130,6 @@ class QueryBuilder extends \yii\base\Object
* @param string $table the table where the data will be deleted from.
* @param string $table the table where the data will be deleted from.
* @param mixed $conditions the conditions that will be put in the WHERE part. Please
* @param mixed $conditions the conditions that will be put in the WHERE part. Please
* refer to {@link where} on how to specify conditions.
* refer to {@link where} on how to specify conditions.
* @param array $params the parameters to be bound to the query.
* @return integer number of rows affected by the execution.
* @return integer number of rows affected by the execution.
*/
*/
public
function
delete
(
$table
,
$conditions
=
''
)
public
function
delete
(
$table
,
$conditions
=
''
)
...
@@ -440,6 +443,10 @@ class QueryBuilder extends \yii\base\Object
...
@@ -440,6 +443,10 @@ class QueryBuilder extends \yii\base\Object
protected
function
buildFrom
(
$query
)
protected
function
buildFrom
(
$query
)
{
{
if
(
empty
(
$query
->
from
))
{
return
''
;
}
$tables
=
$query
->
from
;
$tables
=
$query
->
from
;
if
(
is_string
(
$tables
)
&&
strpos
(
$tables
,
'('
)
!==
false
)
{
if
(
is_string
(
$tables
)
&&
strpos
(
$tables
,
'('
)
!==
false
)
{
return
'FROM '
.
$tables
;
return
'FROM '
.
$tables
;
...
@@ -609,7 +616,7 @@ class QueryBuilder extends \yii\base\Object
...
@@ -609,7 +616,7 @@ class QueryBuilder extends \yii\base\Object
}
}
if
(
!
isset
(
$conditions
[
1
],
$conditions
[
2
]))
{
if
(
!
isset
(
$conditions
[
1
],
$conditions
[
2
]))
{
return
''
;
throw
new
Exception
(
"Operator
$operator
requires at least two operands."
)
;
}
}
$column
=
$conditions
[
1
];
$column
=
$conditions
[
1
];
...
@@ -617,6 +624,15 @@ class QueryBuilder extends \yii\base\Object
...
@@ -617,6 +624,15 @@ class QueryBuilder extends \yii\base\Object
$column
=
$this
->
connection
->
quoteColumnName
(
$column
);
$column
=
$this
->
connection
->
quoteColumnName
(
$column
);
}
}
if
(
$operator
===
'BETWEEN'
||
$operator
===
'NOT BETWEEN'
)
{
if
(
!
isset
(
$conditions
[
3
]))
{
throw
new
Exception
(
"Operator
$operator
requires three operands."
);
}
$value1
=
is_string
(
$conditions
[
2
])
?
$this
->
connection
->
quoteValue
(
$conditions
[
2
])
:
(
string
)
$conditions
[
2
];
$value2
=
is_string
(
$conditions
[
3
])
?
$this
->
connection
->
quoteValue
(
$conditions
[
3
])
:
(
string
)
$conditions
[
3
];
return
"
$column
$operator
$value1
AND
$value2
"
;
}
$values
=
$conditions
[
2
];
$values
=
$conditions
[
2
];
if
(
!
is_array
(
$values
))
{
if
(
!
is_array
(
$values
))
{
$values
=
array
(
$values
);
$values
=
array
(
$values
);
...
...
framework/db/dao/Schema.php
View file @
c63c7838
...
@@ -86,7 +86,7 @@ abstract class Schema extends \yii\base\Object
...
@@ -86,7 +86,7 @@ abstract class Schema extends \yii\base\Object
$db
->
queryCachingDuration
=
-
1
;
$db
->
queryCachingDuration
=
-
1
;
}
}
if
(
!
in_array
(
$name
,
$db
->
schemaCachingExclude
)
&&
$db
->
schemaCachingDuration
>=
0
&&
(
$cache
=
\Yii
::
app
()
->
getComponent
(
$db
->
schemaCacheID
))
!==
null
)
{
if
(
!
in_array
(
$name
,
$db
->
schemaCachingExclude
)
&&
$db
->
schemaCachingDuration
>=
0
&&
(
$cache
=
\Yii
::
$application
->
getComponent
(
$db
->
schemaCacheID
))
!==
null
)
{
$key
=
__CLASS__
.
"/
{
$db
->
dsn
}
/
{
$db
->
username
}
/
{
$name
}
"
;
$key
=
__CLASS__
.
"/
{
$db
->
dsn
}
/
{
$db
->
username
}
/
{
$name
}
"
;
if
((
$table
=
$cache
->
get
(
$key
))
===
false
)
{
if
((
$table
=
$cache
->
get
(
$key
))
===
false
)
{
$table
=
$this
->
loadTableSchema
(
$realName
);
$table
=
$this
->
loadTableSchema
(
$realName
);
...
@@ -156,7 +156,7 @@ abstract class Schema extends \yii\base\Object
...
@@ -156,7 +156,7 @@ abstract class Schema extends \yii\base\Object
public
function
refresh
()
public
function
refresh
()
{
{
$db
=
$this
->
connection
;
$db
=
$this
->
connection
;
if
(
$db
->
schemaCachingDuration
>=
0
&&
(
$cache
=
\Yii
::
app
()
->
getComponent
(
$db
->
schemaCacheID
))
!==
null
)
{
if
(
$db
->
schemaCachingDuration
>=
0
&&
(
$cache
=
\Yii
::
$application
->
getComponent
(
$db
->
schemaCacheID
))
!==
null
)
{
foreach
(
$this
->
_tables
as
$name
=>
$table
)
{
foreach
(
$this
->
_tables
as
$name
=>
$table
)
{
$key
=
__CLASS__
.
":
{
$db
->
dsn
}
/
{
$db
->
username
}
/
{
$name
}
"
;
$key
=
__CLASS__
.
":
{
$db
->
dsn
}
/
{
$db
->
username
}
/
{
$name
}
"
;
$cache
->
delete
(
$key
);
$cache
->
delete
(
$key
);
...
...
framework/logging/DbTarget.php
View file @
c63c7838
...
@@ -71,7 +71,7 @@ class DbTarget extends Target
...
@@ -71,7 +71,7 @@ class DbTarget extends Target
if
(
$this
->
_db
!==
null
)
{
if
(
$this
->
_db
!==
null
)
{
return
$this
->
_db
;
return
$this
->
_db
;
}
}
$this
->
_db
=
\Yii
::
app
()
->
getComponent
(
$this
->
connectionID
);
$this
->
_db
=
\Yii
::
$application
->
getComponent
(
$this
->
connectionID
);
if
(
!
$this
->
_db
instanceof
\yii\db\dao\Connection
)
{
if
(
!
$this
->
_db
instanceof
\yii\db\dao\Connection
)
{
throw
new
\yii\base\Exception
(
'DbTarget.connectionID must refer to a valid application component ID'
);
throw
new
\yii\base\Exception
(
'DbTarget.connectionID must refer to a valid application component ID'
);
}
}
...
...
framework/logging/FileTarget.php
View file @
c63c7838
...
@@ -52,7 +52,7 @@ class FileTarget extends Target
...
@@ -52,7 +52,7 @@ class FileTarget extends Target
{
{
parent
::
init
();
parent
::
init
();
if
(
$this
->
logPath
===
null
)
{
if
(
$this
->
logPath
===
null
)
{
$this
->
logPath
=
\Yii
::
app
()
->
getRuntimePath
();
$this
->
logPath
=
\Yii
::
$application
->
getRuntimePath
();
}
}
if
(
!
is_dir
(
$this
->
logPath
)
||
!
is_writable
(
$this
->
logPath
))
{
if
(
!
is_dir
(
$this
->
logPath
)
||
!
is_writable
(
$this
->
logPath
))
{
throw
new
\yii\base\Exception
(
"Directory '
{
$this
->
logPath
}
' does not exist or is not writable."
);
throw
new
\yii\base\Exception
(
"Directory '
{
$this
->
logPath
}
' does not exist or is not writable."
);
...
...
framework/logging/ProfileTarget.php
View file @
c63c7838
...
@@ -72,7 +72,7 @@ class CProfileLogRoute extends CWebLogRoute
...
@@ -72,7 +72,7 @@ class CProfileLogRoute extends CWebLogRoute
*/
*/
public
function
processLogs
(
$logs
)
public
function
processLogs
(
$logs
)
{
{
$app
=
Yii
::
app
()
;
$app
=
\Yii
::
$application
;
if
(
!
(
$app
instanceof
CWebApplication
)
||
$app
->
getRequest
()
->
getIsAjaxRequest
())
if
(
!
(
$app
instanceof
CWebApplication
)
||
$app
->
getRequest
()
->
getIsAjaxRequest
())
return
;
return
;
...
...
framework/logging/Router.php
View file @
c63c7838
...
@@ -49,7 +49,7 @@ namespace yii\logging;
...
@@ -49,7 +49,7 @@ namespace yii\logging;
* as follows:
* as follows:
*
*
* ~~~
* ~~~
* \Yii::
app()
->log->targets['file']->enabled = false;
* \Yii::
$application
->log->targets['file']->enabled = false;
* ~~~
* ~~~
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Qiang Xue <qiang.xue@gmail.com>
...
@@ -77,7 +77,7 @@ class Router extends \yii\base\ApplicationComponent
...
@@ -77,7 +77,7 @@ class Router extends \yii\base\ApplicationComponent
{
{
parent
::
init
();
parent
::
init
();
\Yii
::
getLogger
()
->
attachEventHandler
(
'onFlush'
,
array
(
$this
,
'processMessages'
));
\Yii
::
getLogger
()
->
attachEventHandler
(
'onFlush'
,
array
(
$this
,
'processMessages'
));
if
((
$app
=
\Yii
::
app
()
)
!==
null
)
{
if
((
$app
=
\Yii
::
$application
)
!==
null
)
{
$app
->
attachEventHandler
(
'onEndRequest'
,
array
(
$this
,
'processMessages'
));
$app
->
attachEventHandler
(
'onEndRequest'
,
array
(
$this
,
'processMessages'
));
}
}
}
}
...
...
framework/logging/Target.php
View file @
c63c7838
...
@@ -128,7 +128,7 @@ abstract class Target extends \yii\base\Component implements \yii\base\Initable
...
@@ -128,7 +128,7 @@ abstract class Target extends \yii\base\Component implements \yii\base\Initable
if
(
$this
->
prefixSession
&&
(
$id
=
session_id
())
!==
''
)
{
if
(
$this
->
prefixSession
&&
(
$id
=
session_id
())
!==
''
)
{
$prefix
[]
=
"[
$id
]"
;
$prefix
[]
=
"[
$id
]"
;
}
}
if
(
$this
->
prefixUser
&&
(
$user
=
\Yii
::
app
()
->
getComponent
(
'user'
,
false
))
!==
null
)
{
if
(
$this
->
prefixUser
&&
(
$user
=
\Yii
::
$application
->
getComponent
(
'user'
,
false
))
!==
null
)
{
$prefix
[]
=
'['
.
$user
->
getName
()
.
']'
;
$prefix
[]
=
'['
.
$user
->
getName
()
.
']'
;
$prefix
[]
=
'['
.
$user
->
getId
()
.
']'
;
$prefix
[]
=
'['
.
$user
->
getId
()
.
']'
;
}
}
...
@@ -151,7 +151,7 @@ abstract class Target extends \yii\base\Component implements \yii\base\Initable
...
@@ -151,7 +151,7 @@ abstract class Target extends \yii\base\Component implements \yii\base\Initable
protected
function
getContextMessage
()
protected
function
getContextMessage
()
{
{
$context
=
array
();
$context
=
array
();
if
(
$this
->
logUser
&&
(
$user
=
\Yii
::
app
()
->
getComponent
(
'user'
,
false
))
!==
null
)
{
if
(
$this
->
logUser
&&
(
$user
=
\Yii
::
$application
->
getComponent
(
'user'
,
false
))
!==
null
)
{
$context
[]
=
'User: '
.
$user
->
getName
()
.
' (ID: '
.
$user
->
getId
()
.
')'
;
$context
[]
=
'User: '
.
$user
->
getName
()
.
' (ID: '
.
$user
->
getId
()
.
')'
;
}
}
...
...
framework/logging/WebTarget.php
View file @
c63c7838
...
@@ -47,7 +47,7 @@ class CWebLogRoute extends CLogRoute
...
@@ -47,7 +47,7 @@ class CWebLogRoute extends CLogRoute
*/
*/
protected
function
render
(
$view
,
$data
)
protected
function
render
(
$view
,
$data
)
{
{
$app
=
Yii
::
app
()
;
$app
=
\Yii
::
$application
;
$isAjax
=
$app
->
getRequest
()
->
getIsAjaxRequest
();
$isAjax
=
$app
->
getRequest
()
->
getIsAjaxRequest
();
if
(
$this
->
showInFireBug
)
if
(
$this
->
showInFireBug
)
...
...
framework/validators/CaptchaValidator.php
View file @
c63c7838
...
@@ -61,13 +61,13 @@ class CaptchaValidator extends Validator
...
@@ -61,13 +61,13 @@ class CaptchaValidator extends Validator
public
function
getCaptchaAction
()
public
function
getCaptchaAction
()
{
{
if
(
strpos
(
$this
->
captchaAction
,
'/'
)
!==
false
)
{
// contains controller or module
if
(
strpos
(
$this
->
captchaAction
,
'/'
)
!==
false
)
{
// contains controller or module
$ca
=
Yii
::
app
()
->
createController
(
$this
->
captchaAction
);
$ca
=
\Yii
::
$application
->
createController
(
$this
->
captchaAction
);
if
(
$ca
!==
null
)
{
if
(
$ca
!==
null
)
{
list
(
$controller
,
$actionID
)
=
$ca
;
list
(
$controller
,
$actionID
)
=
$ca
;
$action
=
$controller
->
createAction
(
$actionID
);
$action
=
$controller
->
createAction
(
$actionID
);
}
}
}
else
{
}
else
{
$action
=
Yii
::
app
()
->
getController
()
->
createAction
(
$this
->
captchaAction
);
$action
=
\Yii
::
$application
->
getController
()
->
createAction
(
$this
->
captchaAction
);
}
}
if
(
$action
===
null
)
{
if
(
$action
===
null
)
{
...
...
framework/validators/StringValidator.php
View file @
c63c7838
...
@@ -82,7 +82,7 @@ class StringValidator extends Validator
...
@@ -82,7 +82,7 @@ class StringValidator extends Validator
}
}
if
(
function_exists
(
'mb_strlen'
)
&&
$this
->
encoding
!==
false
)
{
if
(
function_exists
(
'mb_strlen'
)
&&
$this
->
encoding
!==
false
)
{
$length
=
mb_strlen
(
$value
,
$this
->
encoding
?
$this
->
encoding
:
Yii
::
app
()
->
charset
);
$length
=
mb_strlen
(
$value
,
$this
->
encoding
?
$this
->
encoding
:
\Yii
::
$application
->
charset
);
}
else
{
}
else
{
$length
=
strlen
(
$value
);
$length
=
strlen
(
$value
);
}
}
...
...
tests/unit/framework/db/dao/CommandTest.php
View file @
c63c7838
...
@@ -13,34 +13,27 @@ class CommandTest extends \yiiunit\MysqlTestCase
...
@@ -13,34 +13,27 @@ class CommandTest extends \yiiunit\MysqlTestCase
{
{
$db
=
$this
->
getConnection
(
false
);
$db
=
$this
->
getConnection
(
false
);
// null
$command
=
$db
->
createCommand
();
$command
=
$db
->
createCommand
();
$this
->
assertEquals
(
"SELECT *
\n
FROM "
,
$command
->
sql
);
$this
->
assertEquals
(
null
,
$command
->
sql
);
// string
$sql
=
'SELECT * FROM yii_post'
;
$sql
=
'SELECT * FROM yii_post'
;
$command
=
$db
->
createCommand
(
$sql
);
$command
=
$db
->
createCommand
(
$sql
);
$this
->
assertEquals
(
$sql
,
$command
->
sql
);
$this
->
assertEquals
(
$sql
,
$command
->
sql
);
// Query object
$query
=
new
Query
;
$query
=
new
Query
;
$query
->
select
(
'id'
)
->
from
(
'tbl_user'
);
$command
=
$db
->
createCommand
(
$query
);
$command
=
$db
->
createCommand
(
$query
);
$this
->
assertEquals
(
$query
,
$command
->
query
);
$this
->
assertEquals
(
"SELECT `id`
\n
FROM `tbl_user`"
,
$command
->
sql
);
$query
=
array
(
'select'
=>
'id'
,
'from'
=>
'yii_post'
);
// array
$command
=
$db
->
createCommand
(
$query
);
$command
=
$db
->
createCommand
(
array
(
$this
->
assertEquals
(
$query
,
$command
->
query
->
toArray
());
'select'
=>
'name'
,
}
'from'
=>
'tbl_user'
,
));
function
testReset
()
$this
->
assertEquals
(
"SELECT `name`
\n
FROM `tbl_user`"
,
$command
->
sql
);
{
$db
=
$this
->
getConnection
();
$command
=
$db
->
createCommand
(
'SELECT * FROM yii_user'
);
$command
->
queryRow
();
$this
->
assertNotEquals
(
null
,
$command
->
pdoStatement
);
$this
->
assertEquals
(
'SELECT * FROM yii_user'
,
$command
->
sql
);
$command
->
reset
();
$this
->
assertEquals
(
null
,
$command
->
pdoStatement
);
$this
->
assertNotEquals
(
'SELECT * FROM yii_user'
,
$command
->
sql
);
}
}
function
testGetSetSql
()
function
testGetSetSql
()
...
...
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