Index: trunk/install/php/viewepg.php
===================================================================
--- trunk/install/php/viewepg.php (リビジョン 91)
+++ trunk/install/php/viewepg.php (リビジョン 94)
@@ -91,9 +91,8 @@
$maxdisplay = 8;
- $query = "SELECT stationid, stationname, stationrecch, ontvcode FROM foltia_station WHERE \"ontvcode\" ~~ '%ontvjapan%'
- ";
- $rs = m_query($con, $query, "DBクエリに失敗しました");
- $maxrows = pg_num_rows($rs);
-
+$query = "SELECT count(*) FROM foltia_station WHERE \"ontvcode\" LIKE '%ontvjapan%'";
+//$rs = m_query($con, $query, "DBクエリに失敗しました");
+$rs = sql_query($con, $query, "DBクエリに失敗しました");
+$maxrows = $rs->fetchColumn(0);
if ($maxrows > $maxdisplay){
$pages = ceil($maxrows / $maxdisplay) ;
@@ -138,13 +137,14 @@
$query = "SELECT stationid, stationname, stationrecch, ontvcode
FROM foltia_station
-WHERE \"ontvcode\" ~~ '%ontvjapan%'
+WHERE \"ontvcode\" LIKE '%ontvjapan%'
ORDER BY stationid ASC , stationrecch
-OFFSET $offset LIMIT $maxdisplay
+LIMIT ? OFFSET ?
";
-$slistrs = m_query($con, $query, "DBクエリに失敗しました");
-$stations = pg_num_rows($slistrs);
-for ($i=0 ; $i < $stations ; $i++){
- $rowdata = pg_fetch_row($slistrs, $i);
- $stationhash[$i] = $rowdata[3] ;
+
+//$slistrs = m_query($con, $query, "DBクエリに失敗しました");
+$slistrs = sql_query($con, $query, "DBクエリに失敗しました",array($maxdisplay,$offset));
+while ($rowdata = $slistrs->fetch()) {
+ $stationhash[] = $rowdata[3];
+ $snames[] = $rowdata[1]; // headder
}
@@ -158,34 +158,33 @@
SELECT ontvcode
FROM foltia_station
- WHERE \"ontvcode\" ~~ '%ontvjapan%'
+ WHERE \"ontvcode\" LIKE '%ontvjapan%'
ORDER BY stationid ASC , stationrecch
- OFFSET $offset LIMIT $maxdisplay
+ LIMIT ? OFFSET ?
)
-AND startdatetime >= $start
-AND startdatetime < $epgend
+AND startdatetime >= ?
+AND startdatetime < ?
ORDER BY foltia_epg.startdatetime ASC ";
-$rs = m_query($con, $query, "DBクエリに失敗しました");
+//$rs = m_query($con, $query, "DBクエリに失敗しました");
+$rs = sql_query($con, $query, "DBクエリに失敗しました",array($maxdisplay,$offset,$start,$epgend));
//print "$query
\n";
-$colmnums = pg_num_rows($rs);
-if ($colmnums == 0){
+$rowdata = $rs->fetch();
+if (! $rowdata) {
//番組データがない
$colmnums = 2;
}else{
- for ($i=0 ; $i < $colmnums ; $i++){
- $rowdata = pg_fetch_row($rs, $i);
- $timetablehash["$rowdata[0]"] = ($i + 1);
+ $colmnums = 0;
+ do {
+ $colmnums++;
+ $timetablehash[$rowdata[0]] = $colmnums;
// print "$rowdata[0]:$i+1
\n";
- }
+ } while ($rowdata = $rs->fetch());
}
//print "colmnums $colmnums
\n";
//・局ごとに縦に配列入れていく
-for ($j=0 ; $j < $stations ; $j++){
- $rowdata = pg_fetch_row($slistrs, $j);
- $stationname = $rowdata[3];
-
+foreach ($stationhash as $stationname) {
$epgstart = $start ;
$epgend = calcendtime($start , (8*60));
@@ -193,23 +192,18 @@
SELECT startdatetime , enddatetime , lengthmin , epgtitle , epgdesc , epgcategory ,ontvchannel ,epgid , epgcategory
FROM foltia_epg
-WHERE foltia_epg.ontvchannel = '$stationname' AND
-enddatetime > $epgstart AND
-startdatetime < $epgend
+WHERE foltia_epg.ontvchannel = ? AND
+enddatetime > ? AND
+startdatetime < ?
ORDER BY foltia_epg.startdatetime ASC
";
- $statiodh = m_query($con, $query, "DBクエリに失敗しました");
- $maxrowsstation = pg_num_rows($statiodh);
-
-//print "maxrowsstation $maxrowsstation stationname $stationname
\n";
-
-if ($maxrowsstation == 0) {
+
+// $statiodh = m_query($con, $query, "DBクエリに失敗しました");
+ $statiodh = sql_query($con, $query, "DBクエリに失敗しました",array($stationname,$epgstart,$epgend));
+ $stationrowdata = $statiodh->fetch();
+ if (! $stationrowdata) {
//print("番組データがありません
");
$item[0]["$stationname"] = ">番組データがありません";
}else{
-
-for ($srow = 0; $srow < $maxrowsstation ; $srow++) {
-
-$stationrowdata = pg_fetch_row($statiodh, $srow);
-
+ do {
$printstarttime = substr($stationrowdata[0],8,2) . ":" . substr($stationrowdata[0],10,2);
$tdclass = "t".substr($stationrowdata[0],8,2) . substr($stationrowdata[0],10,2);
@@ -235,5 +229,5 @@
}//if
-}//for
+ } while ($stationrowdata = $statiodh->fetch());
}//if
@@ -291,13 +285,11 @@
//ヘッダ
-for ($i=0;$i<$stations;$i++){
- $rowdata = pg_fetch_row($slistrs, $i);
- print "