[FIX] Fallback to fixed reward without blocks

This commit is contained in:
Sebastian Grewe 2014-02-08 13:46:21 +01:00
parent 5027da0415
commit 08a3200b75

View File

@ -246,7 +246,7 @@ class Block extends Base {
* @param return mixed Block array or false
**/
public function getAverageAmount($limit=10) {
$stmt = $this->mysqli->prepare("SELECT AVG(amount) as avg_amount FROM ( SELECT amount FROM $this->table ORDER BY id DESC LIMIT ?) AS t1");
$stmt = $this->mysqli->prepare("SELECT IFNULL(AVG(amount), " . $this->config['reward'] . ") as avg_amount FROM ( SELECT amount FROM $this->table ORDER BY id DESC LIMIT ?) AS t1");
if ($this->checkStmt($stmt) && $stmt->bind_param('i', $limit) && $stmt->execute() && $result = $stmt->get_result()) {
return $result->fetch_object()->avg_amount;
} else {