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
f03cdf0a
Commit
f03cdf0a
authored
Jul 09, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renamed Command::queryRow() to queryOne().
parent
9c7d0d9b
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
20 additions
and
20 deletions
+20
-20
DbDependency.php
framework/yii/caching/DbDependency.php
+2
-2
ActiveQuery.php
framework/yii/db/ActiveQuery.php
+1
-1
Command.php
framework/yii/db/Command.php
+2
-2
Query.php
framework/yii/db/Query.php
+1
-1
QueryBuilder.php
framework/yii/db/mysql/QueryBuilder.php
+1
-1
Schema.php
framework/yii/db/mysql/Schema.php
+1
-1
DbManager.php
framework/yii/rbac/DbManager.php
+2
-2
DbSession.php
framework/yii/web/DbSession.php
+1
-1
CommandTest.php
tests/unit/framework/db/CommandTest.php
+8
-8
MssqlCommandTest.php
tests/unit/framework/db/mssql/MssqlCommandTest.php
+1
-1
No files found.
framework/yii/caching/DbDependency.php
View file @
f03cdf0a
...
@@ -66,10 +66,10 @@ class DbDependency extends Dependency
...
@@ -66,10 +66,10 @@ class DbDependency extends Dependency
if
(
$db
->
enableQueryCache
)
{
if
(
$db
->
enableQueryCache
)
{
// temporarily disable and re-enable query caching
// temporarily disable and re-enable query caching
$db
->
enableQueryCache
=
false
;
$db
->
enableQueryCache
=
false
;
$result
=
$db
->
createCommand
(
$this
->
sql
,
$this
->
params
)
->
query
Row
();
$result
=
$db
->
createCommand
(
$this
->
sql
,
$this
->
params
)
->
query
One
();
$db
->
enableQueryCache
=
true
;
$db
->
enableQueryCache
=
true
;
}
else
{
}
else
{
$result
=
$db
->
createCommand
(
$this
->
sql
,
$this
->
params
)
->
query
Row
();
$result
=
$db
->
createCommand
(
$this
->
sql
,
$this
->
params
)
->
query
One
();
}
}
return
$result
;
return
$result
;
}
}
...
...
framework/yii/db/ActiveQuery.php
View file @
f03cdf0a
...
@@ -123,7 +123,7 @@ class ActiveQuery extends Query
...
@@ -123,7 +123,7 @@ class ActiveQuery extends Query
public
function
one
(
$db
=
null
)
public
function
one
(
$db
=
null
)
{
{
$command
=
$this
->
createCommand
(
$db
);
$command
=
$this
->
createCommand
(
$db
);
$row
=
$command
->
query
Row
();
$row
=
$command
->
query
One
();
if
(
$row
!==
false
&&
!
$this
->
asArray
)
{
if
(
$row
!==
false
&&
!
$this
->
asArray
)
{
/** @var $class ActiveRecord */
/** @var $class ActiveRecord */
$class
=
$this
->
modelClass
;
$class
=
$this
->
modelClass
;
...
...
framework/yii/db/Command.php
View file @
f03cdf0a
...
@@ -19,7 +19,7 @@ use yii\caching\Cache;
...
@@ -19,7 +19,7 @@ use yii\caching\Cache;
*
*
* To execute a non-query SQL (such as INSERT, DELETE, UPDATE), call [[execute()]].
* To execute a non-query SQL (such as INSERT, DELETE, UPDATE), call [[execute()]].
* To execute a SQL statement that returns result data set (such as SELECT),
* To execute a SQL statement that returns result data set (such as SELECT),
* use [[queryAll()]], [[query
Row
()]], [[queryColumn()]], [[queryScalar()]], or [[query()]].
* use [[queryAll()]], [[query
One
()]], [[queryColumn()]], [[queryScalar()]], or [[query()]].
* For example,
* For example,
*
*
* ~~~
* ~~~
...
@@ -335,7 +335,7 @@ class Command extends \yii\base\Component
...
@@ -335,7 +335,7 @@ class Command extends \yii\base\Component
* results in nothing.
* results in nothing.
* @throws Exception execution failed
* @throws Exception execution failed
*/
*/
public
function
query
Row
(
$fetchMode
=
null
)
public
function
query
One
(
$fetchMode
=
null
)
{
{
return
$this
->
queryInternal
(
'fetch'
,
$fetchMode
);
return
$this
->
queryInternal
(
'fetch'
,
$fetchMode
);
}
}
...
...
framework/yii/db/Query.php
View file @
f03cdf0a
...
@@ -166,7 +166,7 @@ class Query extends Component
...
@@ -166,7 +166,7 @@ class Query extends Component
*/
*/
public
function
one
(
$db
=
null
)
public
function
one
(
$db
=
null
)
{
{
return
$this
->
createCommand
(
$db
)
->
query
Row
();
return
$this
->
createCommand
(
$db
)
->
query
One
();
}
}
/**
/**
...
...
framework/yii/db/mysql/QueryBuilder.php
View file @
f03cdf0a
...
@@ -50,7 +50,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
...
@@ -50,7 +50,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
public
function
renameColumn
(
$table
,
$oldName
,
$newName
)
public
function
renameColumn
(
$table
,
$oldName
,
$newName
)
{
{
$quotedTable
=
$this
->
db
->
quoteTableName
(
$table
);
$quotedTable
=
$this
->
db
->
quoteTableName
(
$table
);
$row
=
$this
->
db
->
createCommand
(
'SHOW CREATE TABLE '
.
$quotedTable
)
->
query
Row
();
$row
=
$this
->
db
->
createCommand
(
'SHOW CREATE TABLE '
.
$quotedTable
)
->
query
One
();
if
(
$row
===
false
)
{
if
(
$row
===
false
)
{
throw
new
Exception
(
"Unable to find column '
$oldName
' in table '
$table
'."
);
throw
new
Exception
(
"Unable to find column '
$oldName
' in table '
$table
'."
);
}
}
...
...
framework/yii/db/mysql/Schema.php
View file @
f03cdf0a
...
@@ -212,7 +212,7 @@ class Schema extends \yii\db\Schema
...
@@ -212,7 +212,7 @@ class Schema extends \yii\db\Schema
*/
*/
protected
function
findConstraints
(
$table
)
protected
function
findConstraints
(
$table
)
{
{
$row
=
$this
->
db
->
createCommand
(
'SHOW CREATE TABLE '
.
$this
->
quoteSimpleTableName
(
$table
->
name
))
->
query
Row
();
$row
=
$this
->
db
->
createCommand
(
'SHOW CREATE TABLE '
.
$this
->
quoteSimpleTableName
(
$table
->
name
))
->
query
One
();
if
(
isset
(
$row
[
'Create Table'
]))
{
if
(
isset
(
$row
[
'Create Table'
]))
{
$sql
=
$row
[
'Create Table'
];
$sql
=
$row
[
'Create Table'
];
}
else
{
}
else
{
...
...
framework/yii/rbac/DbManager.php
View file @
f03cdf0a
...
@@ -303,7 +303,7 @@ class DbManager extends Manager
...
@@ -303,7 +303,7 @@ class DbManager extends Manager
$row
=
$query
->
from
(
$this
->
assignmentTable
)
$row
=
$query
->
from
(
$this
->
assignmentTable
)
->
where
(
array
(
'user_id'
=>
$userId
,
'item_name'
=>
$itemName
))
->
where
(
array
(
'user_id'
=>
$userId
,
'item_name'
=>
$itemName
))
->
createCommand
(
$this
->
db
)
->
createCommand
(
$this
->
db
)
->
query
Row
();
->
query
One
();
if
(
$row
!==
false
)
{
if
(
$row
!==
false
)
{
if
((
$data
=
@
unserialize
(
$row
[
'data'
]))
===
false
)
{
if
((
$data
=
@
unserialize
(
$row
[
'data'
]))
===
false
)
{
$data
=
null
;
$data
=
null
;
...
@@ -479,7 +479,7 @@ class DbManager extends Manager
...
@@ -479,7 +479,7 @@ class DbManager extends Manager
$row
=
$query
->
from
(
$this
->
itemTable
)
$row
=
$query
->
from
(
$this
->
itemTable
)
->
where
(
array
(
'name'
=>
$name
))
->
where
(
array
(
'name'
=>
$name
))
->
createCommand
(
$this
->
db
)
->
createCommand
(
$this
->
db
)
->
query
Row
();
->
query
One
();
if
(
$row
!==
false
)
{
if
(
$row
!==
false
)
{
if
((
$data
=
@
unserialize
(
$row
[
'data'
]))
===
false
)
{
if
((
$data
=
@
unserialize
(
$row
[
'data'
]))
===
false
)
{
...
...
framework/yii/web/DbSession.php
View file @
f03cdf0a
...
@@ -111,7 +111,7 @@ class DbSession extends Session
...
@@ -111,7 +111,7 @@ class DbSession extends Session
$row
=
$query
->
from
(
$this
->
sessionTable
)
$row
=
$query
->
from
(
$this
->
sessionTable
)
->
where
(
array
(
'id'
=>
$oldID
))
->
where
(
array
(
'id'
=>
$oldID
))
->
createCommand
(
$this
->
db
)
->
createCommand
(
$this
->
db
)
->
query
Row
();
->
query
One
();
if
(
$row
!==
false
)
{
if
(
$row
!==
false
)
{
if
(
$deleteOldSession
)
{
if
(
$deleteOldSession
)
{
$this
->
db
->
createCommand
()
$this
->
db
->
createCommand
()
...
...
tests/unit/framework/db/CommandTest.php
View file @
f03cdf0a
...
@@ -99,22 +99,22 @@ class CommandTest extends DatabaseTestCase
...
@@ -99,22 +99,22 @@ class CommandTest extends DatabaseTestCase
$rows
=
$db
->
createCommand
(
'SELECT * FROM tbl_customer WHERE id=10'
)
->
queryAll
();
$rows
=
$db
->
createCommand
(
'SELECT * FROM tbl_customer WHERE id=10'
)
->
queryAll
();
$this
->
assertEquals
(
array
(),
$rows
);
$this
->
assertEquals
(
array
(),
$rows
);
// query
Row
// query
One
$sql
=
'SELECT * FROM tbl_customer ORDER BY id'
;
$sql
=
'SELECT * FROM tbl_customer ORDER BY id'
;
$row
=
$db
->
createCommand
(
$sql
)
->
query
Row
();
$row
=
$db
->
createCommand
(
$sql
)
->
query
One
();
$this
->
assertEquals
(
1
,
$row
[
'id'
]);
$this
->
assertEquals
(
1
,
$row
[
'id'
]);
$this
->
assertEquals
(
'user1'
,
$row
[
'name'
]);
$this
->
assertEquals
(
'user1'
,
$row
[
'name'
]);
$sql
=
'SELECT * FROM tbl_customer ORDER BY id'
;
$sql
=
'SELECT * FROM tbl_customer ORDER BY id'
;
$command
=
$db
->
createCommand
(
$sql
);
$command
=
$db
->
createCommand
(
$sql
);
$command
->
prepare
();
$command
->
prepare
();
$row
=
$command
->
query
Row
();
$row
=
$command
->
query
One
();
$this
->
assertEquals
(
1
,
$row
[
'id'
]);
$this
->
assertEquals
(
1
,
$row
[
'id'
]);
$this
->
assertEquals
(
'user1'
,
$row
[
'name'
]);
$this
->
assertEquals
(
'user1'
,
$row
[
'name'
]);
$sql
=
'SELECT * FROM tbl_customer WHERE id=10'
;
$sql
=
'SELECT * FROM tbl_customer WHERE id=10'
;
$command
=
$db
->
createCommand
(
$sql
);
$command
=
$db
->
createCommand
(
$sql
);
$this
->
assertFalse
(
$command
->
query
Row
());
$this
->
assertFalse
(
$command
->
query
One
());
// queryColumn
// queryColumn
$sql
=
'SELECT * FROM tbl_customer'
;
$sql
=
'SELECT * FROM tbl_customer'
;
...
@@ -178,7 +178,7 @@ class CommandTest extends DatabaseTestCase
...
@@ -178,7 +178,7 @@ class CommandTest extends DatabaseTestCase
$this
->
assertEquals
(
1
,
$command
->
execute
());
$this
->
assertEquals
(
1
,
$command
->
execute
());
$sql
=
'SELECT * FROM tbl_type'
;
$sql
=
'SELECT * FROM tbl_type'
;
$row
=
$db
->
createCommand
(
$sql
)
->
query
Row
();
$row
=
$db
->
createCommand
(
$sql
)
->
query
One
();
$this
->
assertEquals
(
$intCol
,
$row
[
'int_col'
]);
$this
->
assertEquals
(
$intCol
,
$row
[
'int_col'
]);
$this
->
assertEquals
(
$charCol
,
$row
[
'char_col'
]);
$this
->
assertEquals
(
$charCol
,
$row
[
'char_col'
]);
$this
->
assertEquals
(
$floatCol
,
$row
[
'float_col'
]);
$this
->
assertEquals
(
$floatCol
,
$row
[
'float_col'
]);
...
@@ -204,20 +204,20 @@ class CommandTest extends DatabaseTestCase
...
@@ -204,20 +204,20 @@ class CommandTest extends DatabaseTestCase
// default: FETCH_ASSOC
// default: FETCH_ASSOC
$sql
=
'SELECT * FROM tbl_customer'
;
$sql
=
'SELECT * FROM tbl_customer'
;
$command
=
$db
->
createCommand
(
$sql
);
$command
=
$db
->
createCommand
(
$sql
);
$result
=
$command
->
query
Row
();
$result
=
$command
->
query
One
();
$this
->
assertTrue
(
is_array
(
$result
)
&&
isset
(
$result
[
'id'
]));
$this
->
assertTrue
(
is_array
(
$result
)
&&
isset
(
$result
[
'id'
]));
// FETCH_OBJ, customized via fetchMode property
// FETCH_OBJ, customized via fetchMode property
$sql
=
'SELECT * FROM tbl_customer'
;
$sql
=
'SELECT * FROM tbl_customer'
;
$command
=
$db
->
createCommand
(
$sql
);
$command
=
$db
->
createCommand
(
$sql
);
$command
->
fetchMode
=
\PDO
::
FETCH_OBJ
;
$command
->
fetchMode
=
\PDO
::
FETCH_OBJ
;
$result
=
$command
->
query
Row
();
$result
=
$command
->
query
One
();
$this
->
assertTrue
(
is_object
(
$result
));
$this
->
assertTrue
(
is_object
(
$result
));
// FETCH_NUM, customized in query method
// FETCH_NUM, customized in query method
$sql
=
'SELECT * FROM tbl_customer'
;
$sql
=
'SELECT * FROM tbl_customer'
;
$command
=
$db
->
createCommand
(
$sql
);
$command
=
$db
->
createCommand
(
$sql
);
$result
=
$command
->
query
Row
(
array
(),
\PDO
::
FETCH_NUM
);
$result
=
$command
->
query
One
(
array
(),
\PDO
::
FETCH_NUM
);
$this
->
assertTrue
(
is_array
(
$result
)
&&
isset
(
$result
[
0
]));
$this
->
assertTrue
(
is_array
(
$result
)
&&
isset
(
$result
[
0
]));
}
}
...
...
tests/unit/framework/db/mssql/MssqlCommandTest.php
View file @
f03cdf0a
...
@@ -63,7 +63,7 @@ class MssqlCommandTest extends CommandTest
...
@@ -63,7 +63,7 @@ class MssqlCommandTest extends CommandTest
$this
->
assertEquals
(
1
,
$command
->
execute
());
$this
->
assertEquals
(
1
,
$command
->
execute
());
$sql
=
'SELECT int_col, char_col, float_col, CONVERT([nvarchar], blob_col) AS blob_col, numeric_col FROM tbl_type'
;
$sql
=
'SELECT int_col, char_col, float_col, CONVERT([nvarchar], blob_col) AS blob_col, numeric_col FROM tbl_type'
;
$row
=
$db
->
createCommand
(
$sql
)
->
query
Row
();
$row
=
$db
->
createCommand
(
$sql
)
->
query
One
();
$this
->
assertEquals
(
$intCol
,
$row
[
'int_col'
]);
$this
->
assertEquals
(
$intCol
,
$row
[
'int_col'
]);
$this
->
assertEquals
(
$charCol
,
trim
(
$row
[
'char_col'
]));
$this
->
assertEquals
(
$charCol
,
trim
(
$row
[
'char_col'
]));
$this
->
assertEquals
(
$floatCol
,
$row
[
'float_col'
]);
$this
->
assertEquals
(
$floatCol
,
$row
[
'float_col'
]);
...
...
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