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
d8feaeb9
Commit
d8feaeb9
authored
Nov 23, 2013
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored redis AR Query::scalar()
parent
a07facf4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
ActiveQuery.php
framework/yii/redis/ActiveQuery.php
+9
-9
No files found.
framework/yii/redis/ActiveQuery.php
View file @
d8feaeb9
...
@@ -56,7 +56,7 @@ class ActiveQuery extends \yii\base\Component implements ActiveQueryInterface
...
@@ -56,7 +56,7 @@ class ActiveQuery extends \yii\base\Component implements ActiveQueryInterface
* Executes the query and returns all results as an array.
* Executes the query and returns all results as an array.
* @param Connection $db the database connection used to execute the query.
* @param Connection $db the database connection used to execute the query.
* If this parameter is not given, the `db` application component will be used.
* If this parameter is not given, the `db` application component will be used.
* @return ActiveRecord[] the query results. If the query results in nothing, an empty array will be returned.
* @return
array|
ActiveRecord[] the query results. If the query results in nothing, an empty array will be returned.
*/
*/
public
function
all
(
$db
=
null
)
public
function
all
(
$db
=
null
)
{
{
...
@@ -215,20 +215,20 @@ class ActiveQuery extends \yii\base\Component implements ActiveQueryInterface
...
@@ -215,20 +215,20 @@ class ActiveQuery extends \yii\base\Component implements ActiveQueryInterface
/**
/**
* Returns the query result as a scalar value.
* Returns the query result as a scalar value.
* The value returned will be the
first column in the first row
of the query results.
* The value returned will be the
specified attribute in the first record
of the query results.
* @param string $
column name of the column
to select
* @param string $
attribute name of the attribute
to select
* @param Connection $db the database connection used to execute the query.
* @param Connection $db the database connection used to execute the query.
* If this parameter is not given, the `db` application component will be used.
* If this parameter is not given, the `db` application component will be used.
* @return string
|boolean the value of the first column in the first row
of the query result.
* @return string
the value of the specified attribute in the first record
of the query result.
*
False
is returned if the query result is empty.
*
Null
is returned if the query result is empty.
*/
*/
public
function
scalar
(
$
column
,
$db
=
null
)
public
function
scalar
(
$
attribute
,
$db
=
null
)
{
{
$record
=
$this
->
one
(
$db
);
$record
=
$this
->
one
(
$db
);
if
(
$record
=
==
null
)
{
if
(
$record
!
==
null
)
{
return
fals
e
;
return
$record
->
$attribut
e
;
}
else
{
}
else
{
return
$record
->
$column
;
return
null
;
}
}
}
}
...
...
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