public function MongodbXHProfRuns::getRuns in XHProf 8
Same name and namespace in other branches
- 6 modules/xhprof_mongodb/MongodbXHProfRuns.inc \MongodbXHProfRuns::getRuns()
- 7 modules/xhprof_mongodb/MongodbXHProfRuns.inc \MongodbXHProfRuns::getRuns()
This function gets runs based on passed parameters, column data as key, value as the value. Values are escaped automatically. You may also pass limit, order by, group by, or "where" to add those values, all of which are used as is, no escaping.
Parameters
array $stats Criteria by which to select columns:
Return value
resource
File
- modules/
xhprof_mongodb/ MongodbXHProfRuns.inc, line 41 - Definition of MongodbXHProfRuns.
Class
- MongodbXHProfRuns
- Defines a MongoDB storage backend for XHProf.
Code
public function getRuns($stats, $limit = 50, $skip = 0) {
$collection = mongodb_collection('xhprof');
$sort = isset($_GET['order']) ? $_GET['order'] : 'date';
$sort_direction_str = isset($_GET['sort']) ? $_GET['sort'] : 'desc';
$sort_direction = [
'asc' => 1,
'desc' => -1,
];
$cursor = $collection
->find([])
->limit($limit)
->skip($skip)
->sort([
strtolower($sort) => $sort_direction[$sort_direction_str],
]);
$runs = [];
foreach ($cursor as $id => $run) {
$run['run_id'] = $id;
$runs[] = $run;
}
return $runs;
}