From 6486a72b1bfdba18ece7feb23601b2a55cb08899 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Fri, 10 May 2013 22:36:27 +0200 Subject: [PATCH] allow searching blocks in reverse order for sharecounter --- public/include/classes/block.class.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/public/include/classes/block.class.php b/public/include/classes/block.class.php index 6273af98..e24f82d4 100644 --- a/public/include/classes/block.class.php +++ b/public/include/classes/block.class.php @@ -8,7 +8,7 @@ class Block { private $sError = ''; private $table = 'blocks'; // This defines each block - public $height, $blockhash, $confirmations, $difficulty, $time; + public $height, $blockhash, $confirmations, $time, $accounted; public function __construct($debug, $mysqli, $salt) { $this->debug = $debug; @@ -35,6 +35,17 @@ class Block { return false; } + public function getAll($order='DESC') { + $stmt = $this->mysqli->prepare("SELECT * FROM $this->table ORDER BY height $order"); + if ($this->checkStmt($stmt)) { + $stmt->execute(); + $result = $stmt->get_result(); + $stmt->close(); + return $result->fetch_all(MYSQLI_ASSOC); + } + return false; + } + public function addBlock($block) { $stmt = $this->mysqli->prepare("INSERT INTO $this->table (height, blockhash, confirmations, amount, time) VALUES (?, ?, ?, ?, ?)"); if ($this->checkStmt($stmt)) {