チェンジセット 94: trunk/install/perl/foltialib.pl

差分発生行の前後
無視リスト:
コミット日時:
2010/02/28 22:28:26 (15 年前)
コミッタ:
sorshi
ログメッセージ:

SQLite採用

ファイル:

凡例:

変更無し
追加
削除
更新
コピー
移動
  • trunk/install/perl/foltialib.pl

    r83 r94  
    44$path = $0; 
    55$path =~ s/foltialib.pl$//i; 
    6 if ($pwd ne "./"){ 
     6if ($path ne "./"){ 
    77push( @INC, "$path"); 
    88} 
     
    1313use DBI; 
    1414use DBD::Pg; 
    15  
    16  
    17          $DBDriv=$main::DBDriv; 
    18          $DBHost=$main::DBHost; 
    19          $DBPort=$main::DBPort; 
    20          $DBName=$main::DBName; 
     15use DBD::SQLite; 
     16use POSIX qw(strftime); 
     17 
     18$DSN=$main::DSN; 
    2119         $DBUser=$main::DBUser; 
    2220         $DBPass=""; 
     
    4745sub writelog{ 
    4846my $messages = $_[0]; 
    49 my $timestump = `date  +%Y/%m/%d_%H:%M:%S`
     47    my $timestump = strftime("%Y/%m/%d_%H:%M:%S", localtime)
    5048chomp($timestump); 
    5149if ($debugmode == 1){ 
     
    146144my $stationname =  $_[0] ; 
    147145my $stationid ; 
    148 my $DBQuery =  "SELECT count(*) FROM foltia_station WHERE stationname = '$item{ChName}'"; 
    149146 
    150147my $sth; 
    151         $sth = $dbh->prepare($DBQuery); 
    152        $sth->execute(); 
     148    $sth = $dbh->prepare($stmt{'foltialib.getstationid.1'}); 
     149    $sth->execute($item{'ChName'}); 
    153150 my  @stationcount; 
    154151 @stationcount= $sth->fetchrow_array; 
     
    156153if ($stationcount[0] == 1){ 
    157154#チャンネルID取得 
    158 $DBQuery =  "SELECT stationid,stationname FROM foltia_station WHERE stationname = '$item{ChName}'"; 
    159          $sth = $dbh->prepare($DBQuery); 
    160         $sth->execute(); 
     155        $sth = $dbh->prepare($stmt{'foltialib.getstationid.2'}); 
     156        $sth->execute($item{'ChName'}); 
    161157 @stationinfo= $sth->fetchrow_array; 
    162158#局ID 
     
    166162}elsif($stationcount[0] == 0){ 
    167163#新規登録 
    168 $DBQuery =  "SELECT max(stationid) FROM foltia_station"; 
    169          $sth = $dbh->prepare($DBQuery); 
     164        $sth = $dbh->prepare($stmt{'foltialib.getstationid.3'}); 
    170165        $sth->execute(); 
    171166 @stationinfo= $sth->fetchrow_array; 
     
    174169##$DBQuery =  "insert into  foltia_station values ('$stationid'  ,'$item{ChName}','0','','','','','','')"; 
    175170#新規局追加時は非受信局をデフォルトに 
    176 $DBQuery =  "insert into  foltia_station  (stationid , stationname ,stationrecch )  values ('$stationid'  ,'$item{ChName}','-10')"; 
    177  
    178          $sth = $dbh->prepare($DBQuery); 
    179         $sth->execute(); 
     171        $sth = $dbh->prepare($stmt{'foltialib.getstationid.4'}); 
     172        $sth->execute($stationid, $item{'ChName'}, -10); 
    180173#print "Add station;$DBQuery\n"; 
    181 &writelog("foltialib Add station;$DBQuery"); 
     174       &writelog("foltialib Add station;$stmt{'foltialib.getstationid.4'}"); 
    182175}else{ 
    183176 
     
    287280} 
    288281 
    289 my $DBQuery =  "SELECT pid FROM foltia_subtitle WHERE m2pfilename = '$m2pfilename' LIMIT 1 "; 
    290282my $sth; 
    291 $sth = $dbh->prepare($DBQuery); 
    292 $sth->execute(); 
    293 #print "$DBQuery\n"; 
     283    $sth = $dbh->prepare($stmt{'foltialib.getpidbympegfilename.1'}); 
     284    $sth->execute($m2pfilename); 
     285#print "$stmt{'foltialib.getpidbympegfilename.1'}\n"; 
    294286my @pidinfo = $sth->fetchrow_array; 
    295287my $pid  = $pidinfo[0]; 
     
    312304 
    313305if ($updatestatus > 0 ){ 
    314 my $DBQuery =  "UPDATE  foltia_subtitle SET filestatus = $updatestatus , lastupdate      = now() WHERE pid = $pid "; 
    315306my $sth; 
    316 $sth = $dbh->prepare($DBQuery); 
    317 $sth->execute(); 
     307       $sth = $dbh->prepare($stmt{'foltialib.changefilestatus.1'}); 
     308       $sth->execute($updatestatus, $pid); 
    318309return 1; 
    319310}else{ 
     
    351342} 
    352343 
    353 my $DBQuery =  "SELECT filestatus FROM foltia_subtitle  WHERE pid = $pid "; 
    354344my $sth; 
    355 $sth = $dbh->prepare($DBQuery); 
    356 $sth->execute(); 
     345    $sth = $dbh->prepare($stmt{'foltialib.getfilestatus.1'}); 
     346    $sth->execute($pid); 
    357347 
    358348my @statusinfo = $sth->fetchrow_array; 
track feed