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
49a70dc3
Commit
49a70dc3
authored
Dec 01, 2013
by
Klimov Paul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mongo aggregation functions added as draft.
parent
50a7bfea
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
0 deletions
+40
-0
Collection.php
extensions/mongo/Collection.php
+40
-0
No files found.
extensions/mongo/Collection.php
View file @
49a70dc3
...
...
@@ -191,6 +191,46 @@ class Collection extends Object
}
/**
* Returns a list of distinct values for the given column across a collection.
* @param string $column column to use.
* @param array $condition query parameters.
* @return array|boolean array of distinct values, or "false" on failure.
*/
public
function
distinct
(
$column
,
$condition
=
[])
{
return
$this
->
mongoCollection
->
distinct
(
$column
,
$this
->
buildCondition
(
$condition
));
}
/**
* @param $pipeline
* @param array $pipelineOperator
* @return array
*/
public
function
aggregate
(
$pipeline
,
$pipelineOperator
=
[])
{
$args
=
func_get_args
();
return
call_user_func_array
([
$this
->
mongoCollection
,
'aggregate'
],
$args
);
}
/**
* @param mixed $keys
* @param array $initial
* @param \MongoCode|string $reduce
* @param array $options
* @return array
*/
public
function
mapReduce
(
$keys
,
$initial
,
$reduce
,
$options
=
[])
{
if
(
!
(
$reduce
instanceof
\MongoCode
))
{
$reduce
=
new
\MongoCode
(
$reduce
);
}
if
(
array_key_exists
(
'condition'
,
$options
))
{
$options
[
'condition'
]
=
$this
->
buildCondition
(
$options
[
'condition'
]);
}
return
$this
->
mongoCollection
->
group
(
$keys
,
$initial
,
$reduce
,
$options
);
}
/**
* Checks if command execution result ended with an error.
* @param mixed $result raw command execution result.
* @throws Exception if an error occurred.
...
...
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