Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

317
Views
php :: Aggregation ::$avg:: Result undefined in :: mongodb?

this is function aggregation

$query =$et->aggregate(
[
    [ '$match' => [ 'operasi' => '"INSERT"' ] ],
    [ '$group' => [
            '_id' => '$record',
            'avg' => [ '$avg' => '$extime' ]
    ] ],

    ['$sort' => ["_id" => 1]]
]);`

this syntax to show the result

 $rows1 = array();
$rows1['name'] = 'Mongodb';
foreach ($query as $row) {
echo $rows1['data'][]=$row['avg'];
}

then execute :

Notice: Undefined index: avg in E:\xampp\htdocs\RISET\result\insert.php on line 40

this result with var_dump($query);

array(3) { ["waitedMS"]=> int(0) ["result"]=> array(3) { [0]=> array(2) { ["_id"]=> string(2) "10" ["avg"]=> float(0.26921399434408) } [1]=> array(2) { ["_id"]=> string(3) "100" ["avg"]=> float(0.7808530330658) } [2]=> array(2) { ["_id"]=> string(6) "100000" ["avg"]=> float(85.200194120407) } } ["ok"]=> float(1) }

what should i do?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!