Added edge case handling to aggregation example in docs [skip ci]

See https://github.com/yiisoft/yii2/issues/12491#issuecomment-276593948
This commit is contained in:
Alexander Makarov
2017-02-02 20:47:01 +03:00
parent a7518af30b
commit 93fbc55b23

View File

@ -1625,7 +1625,7 @@ class Customer extends \yii\db\ActiveRecord
return null; // this avoid calling a query searching for null primary keys
}
return $this->ordersAggregation[0]['counted'];
return empty($this->ordersAggregation) ? 0 : $this->ordersAggregation[0]['counted'];
}
/**