Error Number: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''3'' at line 1
SELECT * FROM tbl_testimoni order by id DESC limit 3 offset '3'
Filename: D:\wamp\www\obatrohanifinalcopy\system\database\DB_driver.php
Line Number: 330
I'm having problem with my query syntax. I think the problem is in limit and offset query. Because I have tried without limit and offset and my script can work properly. But the pagination function doesn’t work according to my wish.
This is my controller:
$url = $this->uri->segment(3, 0);
$this->load->library('pagination');
$config['base_url'] = site_url() . '/testimonial/all/';
$config['total_rows'] = $this->db->get('tbl_testimoni')->num_rows();
$config['per_page'] = 3;
$this->pagination->initialize($config);
$data['page']=$this->pagination->create_links();
$sql = " SELECT * FROM tbl_testimoni order by id DESC limit 3 offset ? ";
$binds = array($url);
$query = $this->db->query($sql, $binds);
$artikel = $query->result_array();
$data['action'] = 'testimonial/all';
$data['artikel'] = $artikel;
$data['content'] = 'content/testimoni';
$this->load->view('template/default', $data);
and in my view the pagination was called using this code:
<?php if(!empty($page)) echo $page; ?>
and my code doesn’t work properly.
Note: I was using this controller and view in my previous website but there I was using PostgreSQL and it worked.