Skip to content

Commit

Permalink
check for existence of new field during upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
fmido88 authored Feb 4, 2024
1 parent 7457910 commit 7b79717
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion classes/util/balance.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ protected function set_main_balance() {
// Get the balance from the last transaction.
$sort = 'timecreated DESC,id DESC';
$params = ['userid' => $this->userid];
$select = "userid = :userid AND (category IS NULL OR category = 0)";
$select = "userid = :userid";
if ($DB->get_manager()->field_exists(self::TRANSACTION_T, 'category')) {
$select .= " AND (category IS NULL OR category = 0)";
}
$records = $DB->get_records_select(self::TRANSACTION_T, $select, $params, $sort, 'balance, norefund', 0, 1);
$record = reset($records);
// Getting the balance from last transaction.
Expand Down

0 comments on commit 7b79717

Please sign in to comment.