如何检索始终在codeigniter中每页特定日期开始和结束的记录

时间:2013-11-11 09:56:39

标签: php codeigniter

我有一个函数从db中检索数据并设置分页以显示每页7条记录。目前检索到的数据可以在任何一天开始,但我想要做的是每页检索的数据必须始终从Thur开始并在星期五结束

以下是我的控制器功能

public function index()
{
    //Count all records
    $shopID= $this->uri->segment(2);
    $this->db->where('BDP_COST_CENTRE_NUMBER', $shopID);
    $this->data['shops_performances'] = $this->performance_m->get_data();
    $count = (count($this->data['shops_performances']));
    //Set up pagination
    $perpage = 7;
    if ($count > $perpage)
    {
        $config['base_url'] = 'http://bwr/index.php/daily_shop_performance/' . $shopID . '/';
        $config['total_rows'] = $count;
        $config['per_page'] = $perpage;
        $config['uri_segment'] = 3;
        $this->pagination->initialize($config);
        $this->data['pagination']=$this->pagination->create_links();
        $offset = $this->uri->segment(3);
    } else {
        $this->data['pagination']='';
        $offset = 0;
    }
    $shopID= $this->uri->segment(2);
    $this->db->where('BDP_COST_CENTRE_NUMBER', $shopID);
    $this->db->limit($perpage, $offset);
    $this->data['shops_performances'] = $this->performance_m->get_data();
    $this->data['subview'] = 'page/performance_page';
    $this->load->view('_layout_main', $this->data);
}

模型中的函数get_data位于

之下
public function get_data($id)
{
    $this->db->select('*');
    $this->db->from('WHOUSE1.DLY_BWR_MAN_PERFORMANCE');
    $this->db->order_by('BDP_DATE DESC');
    $this->db->join('WHOUSE1.DATE_DIM', 'WHOUSE1.DATE_DIM.DATE_KEY = WHOUSE1.DLY_BWR_MAN_PERFORMANCE.BDP_DATE');
    $query = $this->db->get()->result_array();
    return $query;      
}

我的观点在下面

<table class="table table-striped">
<thead>
    <tr>
        <th>Week Day</th>
        <th>Date</th>
        <th>Takings</th>
        <th>Payout</th>
        <th>Actual Slippage</th>
        <th>Edit</th>
    </tr>
</thead>
<tbody>

<?php if(count($shops_performances)): foreach($shops_performances as $shops_performance): ?>
  <tr>
        <td><?= $shops_performance['DAY_OF_WEEK_DDD']; ?></td>
        <td><?= $shops_performance['BDP_DATE']; ?></td>
        <td><?= $shops_performance['BDP_TAKE']; ?></td>
        <td><?= $shops_performance['BDP_PAYOUT']; ?></td>
        <td><?= $shops_performance['BDP_ACTUAL_SLIPPAGE']?></td>
        <td><?php echo btn_edit('daily_shop_performance/edit/' . $shops_performance['BDP_ID']); ?></td>
</tr>
   <?php endforeach; ?>
<?php else: ?>
    <tr>
        <td colspan="5">We could not find any record.</td>
    </tr>
<?php endif; ?> 
</tbody>
</table>

我想对工作日专栏进行排序

任何想法都将受到赞赏。谢谢。

0 个答案:

没有答案