dev-logs #30

Merged
lopar merged 5 commits from dev-logs into master 2021-01-27 14:08:51 +00:00
Showing only changes of commit 625793c0f5 - Show all commits

View File

@ -4,6 +4,7 @@
* Date: 03.07.2020 * Date: 03.07.2020
* Time: 07:24 * Time: 07:24
*/ */
namespace Battles; namespace Battles;
use Config; use Config;
@ -91,6 +92,7 @@ class Bank
} }
$db = new SQLite3('databases/logs.sqlite'); $db = new SQLite3('databases/logs.sqlite');
$db->exec("CREATE TABLE IF NOT EXISTS bank_logs (id integer constraint bank_logs_pk primary key autoincrement, sender_id integer, receiver_id integer, amount integer, type text, text text)");
$logLine = $db->prepare("INSERT INTO bank_logs (sender_id, receiver_id, amount, type, text) VALUES (?, ?, ?, ?, ?)"); $logLine = $db->prepare("INSERT INTO bank_logs (sender_id, receiver_id, amount, type, text) VALUES (?, ?, ?, ?, ?)");
$logLine->bindParam(1, $senderId, SQLITE3_INTEGER); $logLine->bindParam(1, $senderId, SQLITE3_INTEGER);
$logLine->bindParam(2, $receiverId, SQLITE3_INTEGER); $logLine->bindParam(2, $receiverId, SQLITE3_INTEGER);
@ -174,7 +176,7 @@ class Bank
* @return array * @return array
* @throws Exception * @throws Exception
*/ */
public function withdrawMoney(int $amount):array public function withdrawMoney(int $amount): array
{ {
if ($amount <= 0) { if ($amount <= 0) {
throw new GameException(self::ERROR_WRONG_AMOUNT); throw new GameException(self::ERROR_WRONG_AMOUNT);