db = cs4_open(); $terms = $p; //ページ番号セット $terms['page'] = (empty($terms['page'])) ? "1" : $terms['page'] ; //******************************// // セットメニューリスト取得 // //******************************// //DB接続 $db = DB::connect(constant('KTY_DSN')); if(DB::isError($db)){ echo "DB接続エラー:".DB::errorMessage($db)."\n"; exit; } $where = " u.user_id = '".$p['uid']."' and u.set_id = d.uniq_id and dlt_flg = 0"; $order = " d.date desc"; $sql = "select d.uniq_id, d.date, d.set_name "; $sql.= sprintf(" from contents_data_kty_diet_set_users u, contents_data_kty_diet_set d where %s order by %s",$where,$order); $ret = $db->query($sql); if(DB::isError($ret)){ echo "

クエリの送信が失敗しました。

"; exit; } //件数取得 $count = $ret->numRows(); while($row = $ret->fetchRow(DB_FETCHMODE_ASSOC)){ $array[uniq_id][] = $row['uniq_id']; $array[date][] = $row['date']; $array[set_name][] = $row['set_name']; } //DB開放 $db->disconnect(); // テンプレート読み込み $template =& loadTemplate( $p ); //- 検索エラーハンドリング if($count){ $template->setCurrentBlock('__SerachResult__'); $template->setVariable('count',$count); $template->parseCurrentBlock(); $template->hideBlock('__SearchError__'); }else{ $template->TouchBlock('__SearchError__'); $template->hideBlock('__SearchResult__'); } //-- レシピ一覧作成 $start = ($terms['page'] - 1) * constant('RCP_LIST_COUNT'); $limit = (($start + constant('RCP_LIST_COUNT')) > $count) ? $count : $start + constant('RCP_LIST_COUNT'); for($i = $start;$i < $limit;$i++){ //文字列置換 if('' != $array['date'][$i]){ $ymd = str_replace('-','.',substr($array['date'][$i],0,10)); } $template->setCurrentBlock('__RecipeList__'); $template->setVariable('set_name',$array['set_name'][$i]); $template->setVariable('date',$ymd); $template->setVariable('uniq_id',$array['uniq_id'][$i]); $template->parseCurrentBlock(); } //デバッグ処理 if(constant('BBS_DEBUG_MODE')){ print "
Page Now -> ".$terms['page']."
\n"; print "Total Count -> ".$count."
\n"; print "Show Limit -> ".$limit."
\n"; } $key_str = ""; if($terms['page'] > '1'){ $template->setCurrentBlock('__PagePrev__'); $template->setVariable('prev_page',($terms['page'] - 1)); $template->setVariable('con_id',$p['con_id']); $template->parseCurrentBlock(); }else{ $template->hideBlock('__PagePrev__'); } if($count > $limit){ $template->setCurrentBlock('__PageNext__'); $template->setVariable('next_page',($terms['page'] + 1)); $template->setVariable('con_id',$p['con_id']); $template->parseCurrentBlock(); }else{ $template->hideBlock('__PageNext__'); } $template->setVariable('contents_top',DIET_NAME); $template->show(); //DB開放 cs4_close($this->db); } //var_dump($p); diet_list( $p ); ?>