Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use strict;
- use warnings;
- use DBI;
- use DBIx::QueryLog;
- my $DB_NAME = 'dummy_game';
- my $DB_HOST = 'localhost';
- my $DB_PORT = '3306';
- my $DB_USER = 'root';
- my $DB_PASS = 'hogehoge';
- my $dbh = DBI->connect(
- "DBI:mysql:dbname=$DB_NAME;host=$DB_HOST;port=$DB_PORT",
- "$DB_USER",
- "$DB_PASS"
- );
- my $sth;
- my $row;
- print "■ 発行クエリが簡単に出せる(bind済み)\n";
- $sth = $dbh->prepare("SELECT * FROM item WHERE price < ? LIMIT 3");
- $sth->execute(1000);
- print "\n";
- print "■ 出力カラーも変更できる\n";
- DBIx::QueryLog->color('red');
- $sth = $dbh->prepare("SELECT * FROM user WHERE sex = ? AND age < ? LIMIT 3");
- $sth->execute(('female',12));
- print "\n";
- print "■ EXPLAINまで表示できる\n";
- DBIx::QueryLog->explain(1);
- $row = $dbh->do("SELECT * FROM purchase_history WHERE id > 5 AND amount > 2");
- DBIx::QueryLog->explain(0);
- print "\n";
Add Comment
Please, Sign In to add comment