Closes #35
This commit is contained in:
@@ -2,8 +2,10 @@
|
||||
|
||||
|
||||
namespace Battles;
|
||||
|
||||
use Config;
|
||||
use SQLite3;
|
||||
use SQLite3Result;
|
||||
|
||||
class GameLogs
|
||||
{
|
||||
@@ -52,4 +54,29 @@ class GameLogs
|
||||
$row->execute();
|
||||
$row->close();
|
||||
}
|
||||
|
||||
public static function getUserLogs($userId = null, $type = null): SQLite3Result
|
||||
{
|
||||
$db = new SQLite3(Config::$db_sqlite);
|
||||
|
||||
if ($userId && $type) {
|
||||
$query = "SELECT * FROM users_logs WHERE user_id = ? AND type = ?";
|
||||
$row = $db->prepare($query);
|
||||
$row->bindValue(1, $userId, SQLITE3_INTEGER);
|
||||
$row->bindValue(2, $type, SQLITE3_TEXT);
|
||||
} elseif ($userId && !$type) {
|
||||
$query = "SELECT * FROM users_logs WHERE user_id = ?";
|
||||
$row = $db->prepare($query);
|
||||
$row->bindValue(1, $userId, SQLITE3_INTEGER);
|
||||
} elseif (!$userId && $type) {
|
||||
$query = "SELECT * FROM users_logs WHERE type= ?";
|
||||
$row = $db->prepare($query);
|
||||
$row->bindValue(1, $type, SQLITE3_TEXT);
|
||||
} elseif (!$userId && !$type) {
|
||||
$query = "SELECT * FROM users_logs";
|
||||
$row = $db->prepare($query);
|
||||
}
|
||||
|
||||
return $row->execute();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user