Index: trunk/install/php/index.php =================================================================== --- trunk/install/php/index.php (リビジョン 83) +++ trunk/install/php/index.php (リビジョン 94) @@ -67,34 +67,29 @@ WHERE foltia_tvrecord.tid = foltia_program.tid AND foltia_program.tid = foltia_subtitle.tid -AND foltia_subtitle.enddatetime >= '$now' +AND foltia_subtitle.enddatetime >= ? ORDER BY \"startdatetime\" ASC LIMIT 1000 "; - $reservedrssametid = m_query($con, $query, "DBクエリに失敗しました"); - $reservedmaxrowssameid = pg_num_rows($reservedrssametid); - - if ($reservedmaxrowssameid > 0 ){ - for ($rrow = 0; $rrow < $reservedmaxrowssameid ; $rrow++) { - $rowdata = pg_fetch_row($reservedrssametid, $rrow); +// $reservedrssametid = m_query($con, $query, "DBクエリに失敗しました"); +$reservedrssametid = sql_query($con, $query, "DBクエリに失敗しました",array($now)); +$rowdata = $reservedrssametid->fetch(); +if ($rowdata) { + do { $reservedpidsametid[] = $rowdata[7]; - } + } while ($rowdata = $reservedrssametid->fetch()); + $rowdata = ""; - $rrow = ""; }else{ - $reservedpidsametid = "" ; + $reservedpidsametid = array(); }//end if +$reservedrssametid->closeCursor(); //録画番組検索 $query = " SELECT -foltia_program .tid, -stationname, -foltia_program .title, -foltia_subtitle.countno, -foltia_subtitle.subtitle, -foltia_subtitle.startdatetime , -foltia_subtitle.lengthmin , -foltia_tvrecord.bitrate , -foltia_subtitle.pid + foltia_program.tid, stationname, foltia_program.title, + foltia_subtitle.countno, foltia_subtitle.subtitle, + foltia_subtitle.startdatetime as x, foltia_subtitle.lengthmin, + foltia_tvrecord.bitrate, foltia_subtitle.pid FROM foltia_subtitle , foltia_program ,foltia_station ,foltia_tvrecord WHERE foltia_tvrecord.tid = foltia_program.tid AND foltia_tvrecord.stationid = foltia_station .stationid AND foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid @@ -102,13 +97,8 @@ UNION SELECT -foltia_program .tid, -stationname, -foltia_program .title, -foltia_subtitle.countno, -foltia_subtitle.subtitle, -foltia_subtitle.startdatetime , -foltia_subtitle.lengthmin , -foltia_tvrecord.bitrate , -foltia_subtitle.pid + foltia_program.tid, stationname, foltia_program.title, + foltia_subtitle.countno, foltia_subtitle.subtitle, + foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, + foltia_tvrecord.bitrate, foltia_subtitle.pid FROM foltia_tvrecord LEFT OUTER JOIN foltia_subtitle on (foltia_tvrecord.tid = foltia_subtitle.tid ) @@ -116,18 +106,41 @@ LEFT OUTER JOIN foltia_station on (foltia_subtitle.stationid = foltia_station.stationid ) WHERE foltia_tvrecord.stationid = 0 AND -foltia_subtitle.enddatetime >= '$now' ORDER BY \"startdatetime\" ASC -LIMIT 1000 - "; - - $reservedrs = m_query($con, $query, "DBクエリに失敗しました"); - $reservedmaxrows = pg_num_rows($reservedrs); - - if ($reservedmaxrows > 0 ){ - for ($rrow = 0; $rrow < $reservedmaxrows ; $rrow++) { - $rowdata = pg_fetch_row($reservedrs, $rrow); + foltia_subtitle.enddatetime >= '$now' ORDER BY x ASC +LIMIT 1000 + "; + +//$reservedrs = m_query($con, $query, "DBクエリに失敗しました"); +$query = " +SELECT + foltia_program.tid, stationname, foltia_program.title, + foltia_subtitle.countno, foltia_subtitle.subtitle, + foltia_subtitle.startdatetime as x, foltia_subtitle.lengthmin, + foltia_tvrecord.bitrate, foltia_subtitle.pid +FROM foltia_subtitle , foltia_program ,foltia_station ,foltia_tvrecord +WHERE foltia_tvrecord.tid = foltia_program.tid AND foltia_tvrecord.stationid = foltia_station .stationid AND foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid +AND foltia_subtitle.enddatetime >= ? +UNION +SELECT + foltia_program.tid, stationname, foltia_program.title, + foltia_subtitle.countno, foltia_subtitle.subtitle, + foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, + foltia_tvrecord.bitrate, foltia_subtitle.pid +FROM foltia_tvrecord +LEFT OUTER JOIN foltia_subtitle on (foltia_tvrecord.tid = foltia_subtitle.tid ) +LEFT OUTER JOIN foltia_program on (foltia_tvrecord.tid = foltia_program.tid ) +LEFT OUTER JOIN foltia_station on (foltia_subtitle.stationid = foltia_station.stationid ) +WHERE foltia_tvrecord.stationid = 0 AND + foltia_subtitle.enddatetime >= ? ORDER BY x ASC +LIMIT 1000 + "; +$reservedrs = sql_query($con, $query, "DBクエリに失敗しました",array($now,$now)); + +$rowdata = $reservedrs->fetch(); +if ($rowdata) { + do { $reservedpid[] = $rowdata[8]; - } + } while ($rowdata = $reservedrs->fetch()); }else{ - $reservedpid = ""; + $reservedpid = array(); }//end if @@ -138,13 +151,8 @@ $query = " SELECT -foltia_program .tid, -stationname, -foltia_program .title, -foltia_subtitle.countno, -foltia_subtitle.subtitle, -foltia_subtitle.startdatetime , -foltia_subtitle.lengthmin , -foltia_subtitle.pid , -foltia_subtitle.startoffset + foltia_program.tid, stationname, foltia_program.title, + foltia_subtitle.countno, foltia_subtitle.subtitle, + foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, + foltia_subtitle.pid, foltia_subtitle.startoffset FROM foltia_subtitle , foltia_program ,foltia_station WHERE foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid @@ -153,20 +161,23 @@ LIMIT 1000 "; - $rs = m_query($con, $query, "DBクエリに失敗しました"); - $maxrows = pg_num_rows($rs); - - +$query = " + SELECT + foltia_program.tid, stationname, foltia_program.title, + foltia_subtitle.countno, foltia_subtitle.subtitle, + foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, + foltia_subtitle.pid, foltia_subtitle.startoffset +FROM foltia_subtitle , foltia_program ,foltia_station +WHERE foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid + AND foltia_subtitle.enddatetime >= ? AND foltia_subtitle.countno = '1' +ORDER BY foltia_subtitle.startdatetime ASC +LIMIT 1000 + "; }else{ - $query = " +$query = " SELECT -foltia_program .tid, -stationname, -foltia_program .title, -foltia_subtitle.countno, -foltia_subtitle.subtitle, -foltia_subtitle.startdatetime , -foltia_subtitle.lengthmin , -foltia_subtitle.pid , -foltia_subtitle.startoffset + foltia_program.tid, stationname, foltia_program.title, + foltia_subtitle.countno, foltia_subtitle.subtitle, + foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, + foltia_subtitle.pid, foltia_subtitle.startoffset FROM foltia_subtitle , foltia_program ,foltia_station WHERE foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid @@ -175,10 +186,22 @@ LIMIT 1000 "; - $rs = m_query($con, $query, "DBクエリに失敗しました"); - $maxrows = pg_num_rows($rs); - +$query = " + SELECT + foltia_program.tid, stationname, foltia_program.title, + foltia_subtitle.countno, foltia_subtitle.subtitle, + foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, + foltia_subtitle.pid, foltia_subtitle.startoffset +FROM foltia_subtitle , foltia_program ,foltia_station +WHERE foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid + AND foltia_subtitle.enddatetime >= ? +ORDER BY foltia_subtitle.startdatetime ASC +LIMIT 1000 + "; }//end if -if ($maxrows == 0) { +//$rs = m_query($con, $query, "DBクエリに失敗しました"); +$rs = sql_query($con, $query, "DBクエリに失敗しました",array($now)); +$rowdata = $rs->fetch(); +if (! $rowdata) { header("Status: 404 Not Found",TRUE,404); printtitle(); @@ -211,5 +234,5 @@ columnCount(); ?> @@ -230,8 +253,5 @@ \n"); - } + } while ($rowdata = $rs->fetch()); ?>