助けてください、ヒーローたち!テーブル項目にcate_idというフィールドがあるのですが、具体的にはcate_id=11のデータを出力したいのですが。インターネットで多くの情報を参照し、Thinkphp の開発ドキュメントも読みましたが、これに関する説明はありませんでした。個人的には、主な問題は $item_mod = m("items" であると感じています。 ); これは出力データを決定しますが、なぜ cate_id= だけが出力されるのでしょうか? 11 時のデータを教えてください。
<?phpclass shijiuAction extends frontendAction{ public function _initialize( ) { parent::_initialize( ); $this->_mod = d( "items" ); $this->_cate_mod = d( "items_cate" ); } public function index( ) { $month = mktime( 0, 0, 0, date( "m" ), 1, date( "Y" ) ); $sign_log_mod = m( "sign_log" ); $map['uid'] = $this->visitor->info['id']; $map['sign_date'] = array( "egt", $month ); $sign_info = $sign_log_mod->field( "id,uid,username,sign_date" )->where( $map )->select( ); foreach ( $sign_info as $info ) { $day = date( "d", $info['sign_date'] ); $sign[$day] = $info; } $order = "ordid asc "; $sort = $this->_get( "sort", "trim", "hot" ); $status = $this->_get( "status", "trim", "all" ); switch ( $sort ) { case "new" : $order .= ", coupon_start_time DESC"; break; case "price" : $order .= ", price DESC"; break; case "hot" : $order .= ", volume DESC"; } switch ( $status ) { case "all" : $where['status'] = "underway"; break; case "underway" : $where['status'] = "underway"; break; case "sellout" : $where['status'] = "sellout"; } $where['pass'] = "1"; $index_info['sort'] = $sort; $index_info['status'] = $status; $page_size = c( "ftx_index_page_size" ); $p = $this->_get( "p", "intval", 1 ); $index_info['p'] = $p; $start = $page_size * ( $p - 1 ); $item_mod = m( "items" ); $items_list = $item_mod->where( $where )->order( $order )->limit( $start.",".$page_size )->select( ); $items = array( ); foreach ( $items_list as $key => $val ) { $items[$key] = $val; $items[$key]['class'] = $this->_mod->status( $val['status'], $val['coupon_start_time'], $val['coupon_end_time'] ); } f( "items_list", $items ); $this->assign( "items_list", $items ); $this->assign( "index_info", $index_info ); $count = $item_mod->where( $where )->count( ); $pager = $this->_pager( $count, $page_size ); $this->assign( "page", $pager->fshow( ) ); $this->assign( "total_item", $count ); if ( FALSE === ( $cate_list = f( "cate_list" ) ) ) { $cate_list = d( "items_cate" )->cate_cache( ); } $this->assign( "cate_list", $cate_list ); $item_comment_mod = m( "items_comment" ); $comm_map['status'] = "1"; $comment_list = $item_comment_mod->where( $comm_map )->order( "add_time DESC" )->limit( "0,10" )->select( ); $this->assign( "comment_list", $comment_list ); $this->assign( "nav_curr", "shijiu" ); $this->_config_seo( c( "ftx_seo_config.index" ) ); $this->display( ); } public function so( ) { $sort = $this->_get( "sort", "trim", "hot" ); $status = $this->_get( "status", "trim", "all" ); $cid = $this->_get( "cid", "trim" ); $k = $this->_get( "k", "trim" ); $order = "ordid asc "; switch ( $sort ) { case "new" : $order .= ", coupon_start_time DESC"; break; case "price" : $order .= ", price DESC"; } switch ( $status ) { case "all" : $where['status'] = "underway"; break; case "underway" : $where['status'] = "underway"; break; case "sellout" : $where['status'] = "sellout"; } $where['title'] = array( "like", "%".$k."%" ); $this->assign( "k", $k ); if ( $cid ) { $id_arr = $this->_cate_mod->get_child_ids( $cid, TRUE ); $map['cate_id'] = array( "IN", $id_arr ); $spid = $this->_cate_mod->where( array( "id" => $cate_id ) )->getField( "spid" ); if ( $spid == 0 ) { $spid = $cid; } else { $spid .= $cid; } $this->assign( "cid", $cid ); } $where['pass'] = "1"; $index_info['sort'] = $sort; $index_info['status'] = $status; $page_size = c( "ftx_index_page_size" ); $p = $this->_get( "p", "intval", 1 ); $index_info['p'] = $p; $start = $page_size * ( $p - 1 ); $item_mod = m( "items" ); $items_list = $item_mod->where( $where )->order( $order )->limit( $start.",".$page_size )->select( ); $items = array( ); foreach ( $items_list as $key => $val ) { $items[$key] = $val; $items[$key]['class'] = $this->_mod->status( $val['status'], $val['coupon_start_time'], $val['coupon_end_time'] ); } f( "items_list", $items ); $this->assign( "items_list", $items ); $this->assign( "index_info", $index_info ); $count = $item_mod->where( $where )->count( ); $pager = $this->_pager( $count, $page_size ); $this->assign( "page", $pager->fshow( ) ); $this->assign( "total_item", $count ); if ( FALSE === ( $cate_list = f( "cate_list" ) ) ) { $cate_list = d( "items_cate" )->cate_cache( ); } $this->assign( "cate_list", $cate_list ); $item_comment_mod = m( "items_comment" ); $comment_list = $item_comment_mod->order( "id DESC" )->limit( "0,10" )->select( ); $this->assign( "comment_list", $comment_list ); $this->assign( "nav_curr", "shijiu" ); $this->_config_seo( ); $this->display( ); } public function shortcut( ) { $Shortcut = "[InternetShortcut] \r\n\t\tURL=".__ROOT__." \r\n\t\tIDList= \r\n\t\t[{000214A0-0000-0000-C000-000000000046}] \r\n\t\tProp3=19,2 \r\n\t\t"; header( "Content-type: application/octet-stream" ); header( "Content-Disposition: attachment; filename=".c( "ftx_site_name" ).".url;" ); echo $Shortcut; } public function cate( ) { $cid = $this->_get( "cid", "trim" ); $sort = $this->_get( "sort", "trim", "hot" ); $status = $this->_get( "status", "trim", "all" ); $order = "ordid asc "; switch ( $sort ) { case "new" : $order .= ", coupon_start_time DESC"; break; case "price" : $order .= ", price DESC"; } switch ( $status ) { case "all" : $map['status'] = "underway"; break; case "underway" : $map['status'] = "underway"; break; case "sellout" : $map['status'] = "sellout"; } $id_arr = $this->_cate_mod->get_child_ids( $cid, TRUE ); $map['cate_id'] = array( "IN", $id_arr ); $spid = $this->_cate_mod->where( array( "id" => $cate_id ) )->getField( "spid" ); if ( $spid == 0 ) { $spid = $cid; } else { $spid .= $cid; } $this->assign( "cid", $cid ); $map['pass'] = "1"; $index_info['sort'] = $sort; $index_info['status'] = $status; $index_info['cid'] = $cid; $page_size = c( "ftx_index_page_size" ); $p = $this->_get( "p", "intval", 1 ); $index_info['p'] = $p; $start = $page_size * ( $p - 1 ); $item_mod = m( "items" ); $items_list = $item_mod->where( $map )->order( $order )->limit( $start.",".$page_size )->select( ); $items = array( ); foreach ( $items_list as $key => $val ) { $items[$key] = $val; $items[$key]['class'] = $this->_mod->status( $val['status'], $val['coupon_start_time'], $val['coupon_end_time'] ); } f( "items_list", $items ); $this->assign( "items_list", $items ); $this->assign( "index_info", $index_info ); $count = $item_mod->where( $map )->count( ); $pager = $this->_pager( $count, $page_size ); $this->assign( "page", $pager->fshow( ) ); $this->assign( "total_item", $count ); if ( FALSE === ( $cate_list = f( "cate_list" ) ) ) { $cate_list = d( "items_cate" )->cate_cache( ); } $this->assign( "cate_list", $cate_list ); $item_comment_mod = m( "items_comment" ); $comm_map['status'] = "1"; $comment_list = $item_comment_mod->where( $comm_map )->order( "add_time DESC" )->limit( "0,10" )->select( ); $this->assign( "comment_list", $comment_list ); $this->assign( "nav_curr", "shijiu" ); $cate = d( "items_cate" )->where( array( "id" => $cid ) )->find( ); $this->_config_seo( c( "ftx_seo_config.cate" ), array( "cate_name" => $cate['name'], "seo_title" => $cate['seo_title'], "seo_keywords" => $cate['seo_keys'], "seo_description" => $cate['seo_desc'] ) ); $this->display( ); }}?>
または、テンプレート ページでこれを行うこともできます。
ループに追加します items_list:
2 階の nowphp からの返信を引用: または、テンプレート ページでこれを行うことができます。
ループ items_list:
ループに items_list:
わかりました、ありがとうございます。良い人は安全な生活を送ってください
または、テンプレート ページでこれを行うこともできます。
ループに items_list:
11 に等しくない cate_id の値を出力したい場合は、どのように表現すればよいでしょうか
ループ items_list に次を追加します。
ループ items_list:
< ;neq name='cate_id' value='11'>....
開発ドキュメントを見て、見つけました。 http://www.thinkphp.cn/info/115.html