½é¤á¤ÆMySQL¤ÈPerl¤ÎÏ¢ÂÓ¤Ç¥×¥í¥°¥é¥à¤¬½ñ¤±¤Þ¤·¤¿¡Ê¸åÊÔ¡Ë
<<Á°ÊÔ¤Ø

¤Ï¤¸¤á¤Ëºî¤Ã¤Æ¡¢¼Â¹Ô¤Ï¤µ¤ì¤ë¤¬¤¦¤ó¤È¤â¤¹¤ó¤È¤â¸À¤ï¤Ê¤«¤Ã¤¿¥¹¥¯¥ê¥×¥È¤«¤é·ÇºÜ¡£

#########################################################
#!/usr/bin/perl -w
use strict;
use DBI;

my $dbh = DBI->connect('DBI:mysql:counterdb:localhost:3306', 'nakanishi', 'nakanishidayo') || die "sine";
my $sth = $dbh->prepare("select count from counter_table")|| die "sine";
$sth->execute || die "sine";
my $count;
while ( $count = $sth->fetchrow_array ){
print "$count";
$count++;
}
$sth = $dbh->prepare("update counter_table set count = ?") || die "sine";
$sth->bind_param(1, $count) || die "sine";
$sth->execute;
#########################################################



¤Ä¤¤¤Ç¡¢»²¹Í¥Ú¡¼¥¸¤ò¤ª¤â¤¤¤Ã¤­¤ê»È¤ï¤»¤Æ¤â¤é¤Ã¤¿¥Ð¡¼¥¸¥ç¥ó¡£¤³¤ì¤Ç¤¦¤´¤­¤Þ¤·¤¿¡£

#########################################################
#!/usr/bin/perl

use strict;
use DBI;

my $dsn = 'DBI:mysql:counterdb:localhost:3306';
my $user = 'nakanishi';
my $password = 'nakanishidayo';

my $dbh = DBI->connect($dsn, $user, $password,
{RaiseError => 1, PrintError => 0, AutoCommit => 0 }) || die "$!";
eval {
&mainwork();
$dbh->commit;
$dbh->disconnect;
};
if ( $@ ){
$dbh->rollback;
$dbh->disconnect;
}

exit 0;

#--------------------------
sub mainwork {
my $sql = "select count from counter_table";

my $sth = $dbh->prepare($sql);
$sth->execute;

while ( my $arr_ref = $sth->fetchrow_arrayref ){
my ($count) = @$arr_ref;
print "$count\n";
$count++;
my $sql = "update counter_table set count = ?";
my $sth = $dbh->prepare($sql);
$sth->bind_param(1, $count);
my $rows = $sth->execute;

# Àµ¾ï»þ¤Ï¡¢¤³¤³¤Ç 1¹Ô¤À¤±¹¹¿·¤µ¤ì¤ë¤â¤Î¤È¤¹¤ë¡£
if ( $rows != 1 ){
die "¹¹¿·¹Ô¿ô¤¬°Û¾ï!";
}
}
}
#########################################################


¼Â¹Ô¤µ¤ì¤ë¤¿¤Ó¡¡£±¤º¤ÄÁý¤¨¤ë¡£¤¿¤À¤½¤ì¤À¤±¤Ç¤¹¡¦¡¦¡¦

Äɵ­¡§
½ã¿è¤Ë°Ê²¼¤Î¤è¤¦¤Ë¤¹¤ë¤Èư¤¤¤¿¡£

########################################
#!/usr/bin/perl -w
use strict;
use DBI;

my $dbh = DBI->connect('DBI:mysql:counterdb:localhost:3306', 'nakanishi', 'nakanishidayo') || die "sine";
my $sth = $dbh->prepare("select count from counter_table")|| die "sine";
$sth->execute || die "sine";
my @recode;
my ($count);
while ( @recode = $sth->fetchrow_array ){
$count = $recode[0];
print "$count";
$count++;
}
$sth = $dbh->prepare("update counter_table set count = ?") || die "sine";
$sth->bind_param(1, $count) || die "sine";
$sth->execute;
########################################


¤Ç¤âľ¤Ë$recode[0]++;¡¡¤È¥¤¥ó¥¯¥ê¥á¥ó¥È¤·¤Á¤ã¤¦¤È¤ï¤±¤ï¤«¤é¤ó·ë²Ì¤Ë¡£ $recode[0]¤Ï¥¤¥ó¥¯¥ê¥á¥ó¥È¤µ¤ì¤º¡¡0 ¤Ë¤Ê¤ë¤Ã¤Ý¤¤¡£
¤¢¡¼¡¡¤ï¤±¤ï¤«¤ó¤Í¡¼
¥³¥á¥ó¥È¤òÅê¹Æ¤¹¤ë
Name:
URL:
Comment:

ÈëÌ©:´ÉÍý¼Ô¤Ë¤À¤±É½¼¨¤òµö²Ä¤¹¤ë
¥È¥é¥Ã¥¯¥Ð¥Ã¥¯
¤³¤Îµ­»ö¤Î¥È¥é¥Ã¥¯¥Ð¥Ã¥¯URL
¤³¤Îµ­»ö¤Ë¥È¥é¥Ã¥¯¥Ð¥Ã¥¯¤¹¤ë(FC2¥Ö¥í¥°¥æ¡¼¥¶¡¼)
¥Ö¥í¥°¸¡º÷

¥×¥í¥Õ¥£¡¼¥ë

¥Ó¥ó¥´ÃæÀ¾
Âçºå¹©¶ÈÂç³Ø¾ðÊó²Ê³ØÉô¾ðÊó¥·¥¹¥Æ¥à³Ø²Ê´¶È¡¡³Ø»Î¡Ê¾ðÊ󳨡Ë

Systems Engineering ½¤¹ÔÃæ

FC2¥«¥¦¥ó¥¿¡¼

¥«¥ì¥ó¥À¡¼

07 | 2008/08 | 09
Æü ·î ²Ð ¿å ÌÚ ¶â ÅÚ
- - - - - 1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31 - - - - - -

¥Ö¥í¤È¤â¿½ÀÁ¥Õ¥©¡¼¥à

¤³¤Î¿Í¤È¥Ö¥í¤È¤â¤Ë¤Ê¤ë

| ¥Û¡¼¥à |