[eluser]phantom-a[/eluser]
[quote author="Sumon" date="1220788050"]You can use
Code:
$this->db->orderby("date" , "asc");
in order to get order by clause.[/quote]
I've tried that one too, I does not alter the table for reason. I don't think any data is actually getting passed to it.
Well this my complete code. It works 99% except it loads the rows in the wrong order. its showing the oldest one's first, thats I why I want too use ORDER BY and reverse the order, but it does not work.
*controller
Code:
function cgi_proxies() //Loads the cgi_proxies/index.php/go/cgi_proxies
{
//cgi proxy list settings - EDIT THIS
$data['mybaseurl'] = "http://127.0.0.1"; //set your baseurl like http://www.example.com/ without trailing slash
$data['title'] = "Proxy Toplinks 0.1Beta - CGIPROXIES List"; //cgi_proxies page title
$data['heading'] = "CGI proxies"; // Heading
//stop editing
// load pagination class
$this->load->library('pagination');
$this->load->model('cgiproxies_model');
$config['base_url'] = base_url().'index.php/go/cgi_proxies/';
$config['per_page'] = '5';
$all_result_set = $this->cgiproxies_model->get_cgiproxies('',$config['per_page'],$this->uri->segment(3));
$this->db->orderby("datestamp" , "desc");
$config['total_rows']=$all_result_set['num_rows'];
$data['results']=$all_result_set['result'];
// the rest of pagination settings
$config['full_tag_open'] = '<p>';
$config['full_tag_close'] = '</p>';
$this->pagination->initialize($config);
// load the HTML Table Class
$this->load->library('table');
$this->table->set_heading('ID', 'Title', 'Author', 'Description');
// load the view
$this->load->view('cgi_proxies', $data);
*the model class "cgiproxies_model"
Code:
class cgiproxies_model extends Model {
function __construct(){
parent::Model();
}
function get_cgiproxies($param,$limit=15,$offset){
$this->db->select('*');
$data['num_rows'] = $this->db->count_all_results('links');
$data['result'] = $this->db->get_where('links', array('category' => 1),$limit,$offset);
$this->db->orderby("datestamp" , "asc");
return $data;
}
}