OSDN Git Service

tweet <-> facebook mapping table class
authorISHIKAWA Mutsumi <ishikawa@hanzubon.jp>
Tue, 6 Nov 2012 09:03:24 +0000 (18:03 +0900)
committerISHIKAWA Mutsumi <ishikawa@hanzubon.jp>
Tue, 6 Nov 2012 09:03:24 +0000 (18:03 +0900)
lib/Mubot4FB/DB/TweetMap.pm [new file with mode: 0644]

diff --git a/lib/Mubot4FB/DB/TweetMap.pm b/lib/Mubot4FB/DB/TweetMap.pm
new file mode 100644 (file)
index 0000000..9108c9e
--- /dev/null
@@ -0,0 +1,55 @@
+#!/usr/bin/perl
+#
+# Copyright (c) 2012 ISHIKAWA Mutsumi <ishikawa@hanzubon.jp>
+# This program is covered by the GNU General Public License 2
+#
+package Mubot4FB::DB::Tweet;
+use strict;
+use utf8;
+
+use base 'Mubot4FB::DB';
+
+use Data::Dumper;
+
+sub add_map {
+       my ($me, $db_args) = @_;
+       my $sth = $me->{dbh}->prepare("insert into tweet_map (key_id, tweet_id, user_id, screen_name) VALUES (?,?,?,?)");
+       $sth->bind_param(1, $db_args->{key_id}, SQL_BIGINT);
+       $sth->bind_param(2, $db_args->{tweet_id}, SQL_BIGINT);
+       $sth->bind_param(3, $db_args->{user_id}, SQL_BIGINT);
+       $sth->bind_param(4, $db_args->{screen_name}, SQL_VARCHAR);
+       my $rv = $sth->execute();
+       $sth->finish;
+       return $rv;
+}
+
+sub search_by_key_id {
+       my ($me, $db_args) = @_;
+       my $sth = $me->{dbh}->prepare("select * from tweet_map where key_id = ?");
+       my $rv = $sth->execute();
+
+       my $ret = $sth->fetchrow_hashref();
+       $sth->finish;
+
+       return $ret;
+}
+
+sub delete_map_by_tweet_id {
+       my ($me, $db_args) = @_;
+       my $sth = $me->{dbh}->prepare("delete from tweet_map where tweet_id = ?");
+       $sth->bind_param(1, $db_args->{tweet_id}, SQL_BIGINT);
+
+       my $rv = $sth->execute();
+       $sth->finish;
+       return $rv;
+}
+
+sub delete_map_by_key_id {
+       my ($me, $db_args) = @_;
+       my $sth = $me->{dbh}->prepare("delete from tweet_map where key_id = ?");
+       $sth->bind_param(1, $db_args->{key_id}, SQL_BIGINT);
+
+       my $rv = $sth->execute();
+       $sth->finish;
+       return $rv;
+}