get both valid and invalid round shares

This commit is contained in:
Sebastian Grewe 2013-05-14 12:44:42 +02:00
parent 8b8166bea7
commit 9bf99e3c8e

View File

@ -31,12 +31,24 @@ class Share {
}
public function getRoundShares() {
$stmt = $this->mysqli->prepare("SELECT count(id) AS total FROM $this->table WHERE UNIX_TIMESTAMP(time) >IFNULL((SELECT MAX(time) FROM blocks),0)");
$stmt = $this->mysqli->prepare("
SELECT
( SELECT IFNULL(count(id), 0)
FROM $this->table
WHERE UNIX_TIMESTAMP(time) >IFNULL((SELECT MAX(time) FROM blocks),0)
AND our_result = 'Y' ) as valid,
( SELECT IFNULL(count(id), 0)
FROM $this->table
WHERE UNIX_TIMESTAMP(time) >IFNULL((SELECT MAX(time) FROM blocks),0)
AND our_result = 'N' ) as invalid
");
echo $this->mysqli->error;
if ($this->checkStmt($stmt)) {
$stmt->execute();
$result = $stmt->get_result();
$stmt->close();
return $result->fetch_object()->total;
return $result->fetch_assoc();
}
return false;
}