Sort Query in Codeigniter

Hello Freinds, today i will tell you taht how to sort data from database table in codeigniter sort query.

The Orderby method allows you to sort the results of the query by a given column. If your column has 20 data, you can sort it in ASC or DESC order with the help of this query.

In the lower Query you can see that by using Orderby you can sort the data from 2 fields.

By DESC order

$this->db->from($this->table_name);
$this->db->order_by("id", "desc");
$query = $this->db->get();
return $query->result();

By ASC order

$this->db->from($this->table_name);
$this->db->order_by("id", "asc");
$query = $this->db->get();
return $query->result();

By DESC order With Where

$this->db->from($this->table_name);
$this->db->where("city", "delhi");
$this->db->order_by("id", "desc");
$query = $this->db->get();
return $query->result();

By ASC order With Where

$this->db->from($this->table_name);
$this->db->where("city", "delhi");
$this->db->order_by("id", "asv");
$query = $this->db->get();
return $query->result();
Cialis (Tadalafil) är den främsta konkurrenten till Viagra (Sildenafil) på marknaden för erektil dysfunktion. köpa Cialis i Sverige föredras av många på grund av sin längre varaktighet och anses vara det mest kostnadseffektiva varumärkesbaserade ED-läkemedlet som finns tillgängligt i Sverige. Cialis finns i två varianter: Cialis och Cialis Daily, och fyra olika doseringar: 2,5 mg, 5 mg, 10 mg och 20 mg, erbjuder Cialis också en rad olika alternativ för att passa patientens behov.