0

我是codeigniter的新手。我正在使用分页。分页链接显示得很好,但是当我点击任何链接时,我就会退出。这是我的代码,请检查是否需要更正

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Packages extends CI_Controller {

function __construct() {
    parent::__construct();

    $this->load->model('admin_packages');
    $this->load->model('common_model'); 
    $this->load->helper(array('form', 'url'));      
    $this->load->library('form_validation');
    $this->load->library('pagination');
    $this->load->library('common');

}


function packages()
{

if(!$this->session->userdata('userid'))
    redirect('index.php/users/login'); 
    $ofset=0;
$config['base_url']='http://localhost/index.php/vehicles/packages/';            
$config['total_rows']=$this>common_model>get_countt('packages_purchased','user_id',$this->session->userdata('userid'));
        $config['per_page'] = '10';
        $config['use_page_numbers'] = TRUE;
        $config['full_tag_open'] = '<p align="center">';
        $config['full_tag_close'] = '</p>';
        $this->pagination->initialize($config);  
        if($this->uri->segment(3))
        $ofset=($this->uri->segment(3)-1)*$config['per_page'];

    $uid=$this->session->userdata('userid');
    $bal=$this->vehicle->available_balance($uid);
    $arr['balanc']=$bal->mots;
    $arr['dtee']=$bal->dt;
    $arr['pack']=$this->common_model->get_alldetails('packages','status',1);
$arr['det']=$this->vehicle->purchased_packages($this->session->userdata('userid'),$ofset,$config['per_page']);

   $arr['page_title']='Reminder | Automated TEXT and Email Alerts for Garage Owners';   
   $this->breadcrumb->append_crumb("My Account<span>&nbsp;&#8250;&nbsp;<span>Packages", '/page');
    $this->load->template('vehicles/purchased_packages',$arr);
}
4

1 回答 1

0

$config['base_url'] = base_url().'vehicles/packages'

省略index.php

如果它将您重定向到注销,您确定验证当前用户的会话正在工作吗?

您是否尝试过使用this->db->last_query()来显示查询的外观?因为这里的这段代码

if($this->uri->segment(3))
$ofset=($this->uri->segment(3)-1)*$config['per_page'];

会给你一个偏移量90

在您的模型上$this->vehicle->purchased_packages添加

$this->db->last_query();
die();

在返回之前,这将打印出您刚刚进行的查询,您可以查看您是否获得了正确的数据。

于 2013-05-16T13:41:04.823 回答