Merge pull request #544 from TheSerapher/issue-542

Issue 542
This commit is contained in:
Sebastian Grewe 2013-08-01 00:01:49 -07:00
commit 8abfa9b355
2 changed files with 9 additions and 2 deletions

View File

@ -8,6 +8,7 @@ class Transaction {
private $sError = '';
private $table = 'transactions';
private $tableBlocks = 'blocks';
public $num_rows = 0;
public function __construct($debug, $mysqli, $config, $block, $user) {
$this->debug = $debug;
@ -89,6 +90,7 @@ class Transaction {
$this->debug->append("STA " . __METHOD__, 4);
$sql = "
SELECT
SQL_CALC_FOUND_ROWS
t.id AS id,
a.username as username,
t.type AS type,
@ -142,8 +144,13 @@ class Transaction {
LIMIT ?,?
";
$stmt = $this->mysqli->prepare($sql);
if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $start, $limit) && $stmt->execute() && $result = $stmt->get_result())
if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $start, $limit) && $stmt->execute() && $result = $stmt->get_result()) {
// Fetch matching row count
$num_rows = $this->mysqli->prepare("SELECT FOUND_ROWS() AS num_rows");
if ($num_rows->execute() && $row_count = $num_rows->get_result()->fetch_object()->num_rows)
$this->num_rows = $row_count;
return $result->fetch_all(MYSQLI_ASSOC);
}
$this->debug->append('Unable to fetch transactions');
return false;
}

View File

@ -13,7 +13,7 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) {
$iLimit = 30;
$debug->append('No cached version available, fetching from backend', 3);
$aTransactions = $transaction->getAllTransactions(@$_REQUEST['start'], @$_REQUEST['filter'], $iLimit);
$iCountTransactions = $transaction->getCountAllTransactions();
$iCountTransactions = $transaction->num_rows;
$aTransactionTypes = $transaction->getTypes();
if (!$aTransactions) $_SESSION['POPUP'][] = array('CONTENT' => 'Could not find any transaction', 'TYPE' => 'errormsg');
$smarty->assign('LIMIT', $iLimit);