add method to return shares table name, added getRoundShares

This commit is contained in:
Sebastian Grewe 2013-05-13 23:28:11 +02:00
parent 910ebcd6bc
commit c4d5e31bac

View File

@ -26,6 +26,21 @@ class Share {
return $this->sError;
}
public function getTableName() {
return $this->table;
}
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)");
if ($this->checkStmt($stmt)) {
$stmt->execute();
$result = $stmt->get_result();
$stmt->close();
return $result->fetch_object()->total;
}
return false;
}
public function getSharesForAccounts($previous_upstream=0, $current_upstream) {
$stmt = $this->mysqli->prepare("SELECT
a.id,
@ -65,23 +80,6 @@ class Share {
return false;
}
public function getRoundShares($previous_upstream=0, $current_upstream) {
$stmt = $this->mysqli->prepare("SELECT
count(id) as total
FROM $this->table
WHERE our_result = 'Y'
AND id BETWEEN ? AND ?
");
if ($this->checkStmt($stmt)) {
$stmt->bind_param('ii', $previous_upstream, $current_upstream);
$stmt->execute();
$result = $stmt->get_result();
$stmt->close();
return $result->fetch_object()->total;
}
return false;
}
public function moveArchive($previous_upstream=0, $current_upstream,$block_id) {
$archive_stmt = $this->mysqli->prepare("INSERT INTO shares_archive (share_id, username, our_result, upstream_result, block_id)
SELECT id, username, our_result, upstream_result, ?