Php CodeIgniter分页结果问题
我正试图让它工作,但失败了 我将订单输出到仪表板上,并希望将其拆分为活动订单和完整订单,我可以在它们之间切换选项卡,并需要分页来单独处理它们 控制器:Php CodeIgniter分页结果问题,php,codeigniter,pagination,Php,Codeigniter,Pagination,我正试图让它工作,但失败了 我将订单输出到仪表板上,并希望将其拆分为活动订单和完整订单,我可以在它们之间切换选项卡,并需要分页来单独处理它们 控制器: public function index($offset = 0) { $total_rows_active = $this->orders_m->where_in('`status`', array('pending', 'processing', 'processed', 'shipping'))->count
public function index($offset = 0)
{
$total_rows_active = $this->orders_m->where_in('`status`', array('pending', 'processing', 'processed', 'shipping'))->count_all();
$total_rows_complete = $this->orders_m->where_in('`status`', array('complete'))->count_all();
$this->data->pagination_active = create_pagination('admin/store/index', $total_rows_active);
$this->data->pagination_complete = create_pagination('admin/store/index', $total_rows_complete);
// Using this data, get the relevant results
$this->data->items_active = $this->orders_m->limit($this->data->pagination_active['limit'], $this->data->pagination_active['offset'])->order_by('order_date','desc')->get_all();
$this->data->items_complete = $this->orders_m->limit($this->data->pagination_complete['limit'], $this->data->pagination_complete['offset'])->order_by('order_date','desc')->get_all();
// here we use MY_Model's get_all() method to fetch everything
//$this->data->items = $this->orders_m->limit(Settings::get('records_per_page'))->offset($offset * Settings::get('records_per_page'))->order_by('order_date','desc')->get_all();
//$this->data->pagination = create_pagination('admin/store/index', $this->orders_m->count_all());
$this->data->check_stock_levels = $this->stock_levels_m->get_all();
$this->data->stats = $this->stats_m->get_all();
// Build the view with store/views/admin/items.php
$this->template->title($this->module_details['name'])
/*->append_metadata('<script type="text/javascript" src="https://www.google.com/jsapi"></script>')*/
->append_js('jquery/jquery.flot.js')
->append_js('module::stats.js')
->build('admin/dashboard', $this->data);
}
视图:
如果有两列或更多列具有相同的名称,在您的案例状态中,在不同的选项卡中,在您的where条件中,您必须更加精确。尝试将:table\u name
status
添加到您的where\u中,条件如下:
$total_rows_active = $this->orders_m->where_in('`'.$this->db->dbprefix('store_transactions').'`.`status`', array('pending', 'processing', 'processed', 'shipping'))->count_all();
$total_rows_complete = $this->orders_m->where_in('`'.$this->db->dbprefix('store_transactions').'`.`status`', array('complete'))->count_all();
实际问题是什么?问题是返回的数据不正确,需要通过“状态”返回,但当我在模型中使用“where_in(“
status
”,array('complete')”)时,我会收到错误,说状态不明确。查看模型中的前2个联接。在不同的表中使用相同的字段吗?不,我正在使用的字段是模型函数中的内容。我知道我的问题是什么,在我的“存储订单历史记录”表中,状态字段有以下内容:“待定”、“处理”、“已处理”、“发货”,“完成”以及相同的订单id和时间戳,我需要了解如何选择最新的时间戳
<div class="tabs">
<ul class="tab-menu">
<li><a href="#active_orders"><span>Active Orders</span></a></li>
<li><a href="#complete_orders"><span>Completed Orders</span></a></li>
</ul>
<div id="active_orders"><?php print_r($items_active); ?><?php if(!empty($pagination_active['links'])): ?>
<div class="paginate">
<?php echo $pagination_active['links'];?>
</div>
<?php endif; ?>
</div>
<div id="complete_orders"><?php print_r($items_complete); ?><?php if(!empty($pagination_complete['links'])): ?>
<div class="paginate">
<?php echo $pagination_complete['links'];?>
</div>
<?php endif; ?>
</div>
</div>
$total_rows_active = $this->orders_m->where_in('`'.$this->db->dbprefix('store_transactions').'`.`status`', array('pending', 'processing', 'processed', 'shipping'))->count_all();
$total_rows_complete = $this->orders_m->where_in('`'.$this->db->dbprefix('store_transactions').'`.`status`', array('complete'))->count_all();