aboutsummaryrefslogtreecommitdiff
path: root/lib/MasterServer/Database/Pg/dbCiphers.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/MasterServer/Database/Pg/dbCiphers.pm')
-rwxr-xr-xlib/MasterServer/Database/Pg/dbCiphers.pm18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/MasterServer/Database/Pg/dbCiphers.pm b/lib/MasterServer/Database/Pg/dbCiphers.pm
index e2a5784..e099f88 100755
--- a/lib/MasterServer/Database/Pg/dbCiphers.pm
+++ b/lib/MasterServer/Database/Pg/dbCiphers.pm
@@ -1,15 +1,23 @@
-
package MasterServer::Database::Pg::dbCiphers;
use strict;
use warnings;
use Exporter 'import';
-our @EXPORT = qw| clear_ciphers
+our @EXPORT = qw| check_cipher_count
+ clear_ciphers
insert_cipher
get_game_props |;
################################################################################
+## Check if ciphers exist
+################################################################################
+sub check_cipher_count {
+ my $self = shift;
+ return $self->db_all('SELECT count(*) as num from games')->[0]->{num};
+}
+
+################################################################################
## Clear all existing ciphers from the database
################################################################################
sub clear_ciphers {
@@ -43,15 +51,13 @@ sub insert_cipher {
################################################################################
## get the cipher, description and default port that goes with given gamename
+## returns only the first item if multiple items
################################################################################
sub get_game_props {
my ($self, $gn) = @_;
# get cipher from db if gamename exists
- return $self->{dbh}->selectall_arrayref(
- 'SELECT * FROM games WHERE gamename = ?',
- {Slice=>{}},
- lc $gn)->[0];
+ return $self->db_all('SELECT * FROM games WHERE gamename = ?', lc $gn)->[0];
}
1;