Mercurial > epgrec.yaz
view Keyword.class.php @ 149:5b192e94f49d
fix: 予約済み定数を使ってしまったミスを修正。エラーレベルに警告を追加
author | epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp> |
---|---|
date | Sat, 27 Mar 2010 16:04:54 +0900 |
parents | 2cb414518ccd |
children | 4afd353b4507 784e3c82926e |
line wrap: on
line source
<?php include_once('config.php'); include_once( INSTALL_PATH . "/DBRecord.class.php" ); include_once( INSTALL_PATH . "/reclib.php" ); include_once( INSTALL_PATH . "/Reservation.class.php" ); include_once( INSTALL_PATH . '/Settings.class.php' ); include_once( INSTALL_PATH . '/recLog.inc.php' ); class Keyword extends DBRecord { public function __construct($property = null, $value = null ) { try { parent::__construct(KEYWORD_TBL, $property, $value ); } catch( Exception $e ) { throw $e; } } static public function search( $keyword = "", $use_regexp = false, $type = "*", $category_id = 0, $channel_id = 0, $weekofday = 7, $prgtime = 24, $limit = 300 ) { $sts = Settings::factory(); $dbh = @mysql_connect($sts->db_host, $sts->db_user, $sts->db_pass ); // <c罎膣≪ $options = " WHERE starttime > '".date("Y-m-d H:i:s", time() + $sts->padding_time + 60 )."'"; if( $keyword != "" ) { if( $use_regexp ) { $options .= " AND CONCAT(title,description) REGEXP '".mysql_real_escape_string($keyword)."'"; } else { // 茹茹 // 翫絲上 $f_zennum = preg_match('/[0-9]/u', $keyword ); $f_zenal = preg_match('/[a-zA-Z]/u', $keyword ); $options .= " AND ( CONCAT(title,' ',description) like '%".mysql_real_escape_string($keyword)."%'"; if( $f_zennum ) { $options .= " OR CONCAT(title,' ',description) like '%".mysql_real_escape_string(mb_convert_kana( $keyword, 'KVN',"UTF-8" ))."%'"; } if( $f_zenal ) { $options .= " OR CONCAT(title,' ',description) like '%".mysql_real_escape_string(mb_convert_kana( $keyword, 'KVR', "UTF-8" ))."%'"; } if( $f_zenal && $f_zennum ) { $options .= " OR CONCAT(title,' ',description) like '%".mysql_real_escape_string(mb_convert_kana( $keyword, 'KVRN', "UTF-8" ))."%'"; } $options .= ") "; } } if( $type != "*" ) { $options .= " AND type = '".$type."'"; } if( $category_id != 0 ) { $options .= " AND category_id = '".$category_id."'"; } if( $channel_id != 0 ) { $options .= " AND channel_id = '".$channel_id."'"; } if( $weekofday != 7 ) { $options .= " AND WEEKDAY(starttime) = '".$weekofday."'"; } if( $prgtime != 24 ) { $options .= " AND time(starttime) BETWEEN cast('".sprintf( "%02d:00:00", $prgtime)."' as time) AND cast('".sprintf("%02d:59:59", $prgtime)."' as time)"; } $options .= " ORDER BY starttime ASC LIMIT ".$limit ; $recs = array(); try { $recs = DBRecord::createRecords( PROGRAM_TBL, $options ); } catch( Exception $e ) { throw $e; } return $recs; } private function getPrograms() { if( $this->id == 0 ) return false; $recs = array(); try { $recs = self::search( trim($this->keyword), $this->use_regexp, $this->type, $this->category_id, $this->channel_id, $this->weekofday, $this->prgtime ); } catch( Exception $e ) { throw $e; } return $recs; } public function reservation() { if( $this->id == 0 ) return; $precs = array(); try { $precs = $this->getPrograms(); } catch( Exception $e ) { throw $e; } // 筝羂牙私膣 foreach( $precs as $rec ) { try { if( $rec->autorec ) { Reservation::simple( $rec->id, $this->id, $this->autorec_mode ); reclog( "Keyword.class::若若ID".$this->id."牙祉篋膣"); usleep( 100 ); // 障腥冴? } } catch( Exception $e ) { // ∴ } } } public function delete() { if( $this->id == 0 ) return; $precs = array(); try { $precs = $this->getPrograms(); } catch( Exception $e ) { throw $e; } // 筝羂c潟祉 foreach( $precs as $rec ) { try { $reserve = new DBRecord( RESERVE_TBL, "program_id", $rec->id ); // 篋膣水 if( $reserve->autorec ) { Reservation::cancel( $reserve->id ); usleep( 100 ); // 障腥冴? } } catch( Exception $e ) { // ∴ } } try { parent::delete(); } catch( Exception $e ) { throw $e; } } // static<潟激с潟若若ゃс static function createKeywords( $options = "" ) { $retval = array(); $arr = array(); try{ $tbl = new self(); $sqlstr = "SELECT * FROM ".$tbl->table." " .$options; $result = $tbl->__query( $sqlstr ); } catch( Exception $e ) { throw $e; } if( $result === false ) throw new exception("潟若絖障"); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { array_push( $retval, new self('id', $row['id']) ); } return $retval; } public function __destruct() { parent::__destruct(); } } ?>