[eluser]zacksyah[/eluser]
i've error for page two pagination. This below link of pagination
http://localhost/ci/index.php/controller...iewnosql/5
this is code from apps
Code:
<?php
class Controller_nosql extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->library('session');
$this->load->model('model_nosql','bps');
$this->load->library('pagination');
$this->load->library('Mongo');
}
function index($offset='') {
$per_page = 5;
$config['base_url'] = site_url(). '/controller_nosql/viewnosql';
$total = $this->bps->count();
//$query = "{"."'province_id':'94'"."},{"."province_id:1"."}";
$data['bps'] = $this->bps->all_pagination($per_page, $offset);
$config['per_page'] = $per_page;
$config['total_rows'] = $total;
$config['uri_segment'] = 3;
//$config['base_url'] = $base_url;
$this->pagination->initialize($config);
$data['create_links'] = $this->pagination->create_links();
$this->load->view('viewnosql', $data);
}
function cari($offset=''){
$this->load->library('pagination');
$total = 0;
$per_page = 5;
$config['base_url'] = site_url() . '/controller_nosql/cari';
$data['bps'] = $this->bps->search();
$config['per_page'] = $per_page;
$config['total_rows'] = $total;
$config['uri_segment'] = 3;
$this->pagination->initialize($config);
$data['create_links'] = $this->pagination->create_links();
$this->load->view('viewnosql', $data);
}
}
?>
Code:
<?php
class Model_nosql extends CI_Model {
function __contruct() {
parent::__construct();
$this->connection = new Mongo('localhost:27017');
}
function MongoAll() {
$lihat = array();
$lihat = $this->mongo->db->bps->find();
return $lihat;
}
function all_dropdown() {
$lihat = array();
$query = $this->mongo->db->bps->find(array(), array('_id' > 1, 'nama' => 1));
foreach ($query as $row) {
$query[(string) $row['_id']] = $row['province_id'];
}
return $query;
}
function update($_id) {
$author = array(
'province_id' => $this->input->post('province_id'),
'nama_propinsi' => $this->input->post('nama_propinsi'),
'regency_id' => $this->input->post('regency_id'),
'regency_name' => $this->input->post('regency_name'),
'sub-district_id' => $this->input->post('sub-district_id'),
'sub-district_name' => $this->input->post('sub-district_name'),
'village_id' => $this->input->post('village_id'),
'village_name' => $this->input->post('village_name'),
'NBS' => $this->input->post('NBS'),
'NSBS' => $this->input->post('NSBS'),
'NUS' => $this->input->post('NUS'),
'NUP' => $this->input->post('NUP'),
'sample_type' => $this->input->post('sample_type'),
'sample_name' => $this->input->post('sample_name'),
'name' => $this->input->post('name'),
'address' => $this->input->post('address'),
'RT' => $this->input->post('RT'),
'RW' => $this->input->post('RW'),
'zip_code' => $this->input->post('zip_code'),
'phone' => $this->input->post('phone'),
'EXT' => $this->input->post('EXT'),
'FAX' => $this->input->post('FAX'),
'EMAIL' => $this->input->post('EMAIL'),
'phone' => $this->input->post('HOMEPAGE'),
'activity' => $this->input->post('activity'),
'category_code' => $this->input->post('category_code'),
'category_name' => $this->input->post('category_name'),
'kbli_code' => $this->input->post('kbli_code'),
'label' => $this->input->post('label'),
'business_name' => $this->input->post('business_name'),
);
$criteria = array('_id' => new MongoID($_id));
$this->mongo->db->bps->update($criteria, array('$set' => $author));
}
function all_pagination($limit, $offset) {
$authors = array();
if ($offset) {
$authors = $this->mongo->db->bps->find()->limit($limit)->skip($offset)->sort(array('_id' => -1));
} else {
$authors = $this->mongo->db->bps->find()->limit($limit)->sort(array('_id' => -1));
}
return $authors;
}
function find_by_id($_id) {
$author = array();
$author = $this->mongo->db->bps->findOne(array('_id' => new MongoID($_id)));
return $author;
}
function count() {
$total = $this->mongo->db->bps->count();
return $total;
}
function search() {
$c = $this->input->POST('cari');
return $this->mongo->db->bps->find(array('business_name' => $c));
}
}
?>
what's wrong with the apps code? please help me, thanks in advance