Skip to content

Commit

Permalink
add new function, fetch_grab_row, I might have this return who did th…
Browse files Browse the repository at this point in the history
…e grab as well as the actual message.
  • Loading branch information
James S authored and CodeBlock committed Dec 24, 2009
1 parent 46a1db0 commit a0e29f9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Grab.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ my $dbh = DBI->connect("dbi:SQLite:dbname=db_blink.sqlite3","","",{AutoCommit=>1
my $new_grab = $dbh->prepare("INSERT INTO grabs(by,who,message,channel) VALUES(?,?,?,?)");
my $fetch_grab = $dbh->prepare("SELECT message FROM grabs WHERE who=? AND channel=? ORDER BY RANDOM()");

#debugging function
sub fetch_grab_row {
my ($who, $channel) = @_;
$fetch_grab->execute($who,$channel);
return $fetch_grab->fetchrow_array();
}

sub commit {
my($commitby,$who,$said,$channel) = @_;
if($new_grab->execute($commitby,$who,$said,$channel)){
Expand All @@ -27,8 +34,7 @@ sub fetchr {
my $who = shift;
my $channel = shift;

$fetch_grab->execute($who,$channel);
my @data = $fetch_grab->fetchrow_array();
my @data = fetch_grab_row($who, $channel);
if(int(@data) != 0){
return @data[int(rand(@data))]
} else {
Expand Down

0 comments on commit a0e29f9

Please sign in to comment.