James Fox
James Fox

Reputation: 27

How can use order-by in codeigniter?

I know this is simple but i didn't complete it.

$query = $this->db->get_where('prepared_forms', array('topic' => $this->input-    >post('prepared_topics')));
$new_form = $query->row_array();

How can order prepared forms order by topic name (ASC)?

Upvotes: 2

Views: 19160

Answers (3)

Ryu Amy
Ryu Amy

Reputation: 41

Try this:

$query = $this->db->order_by('topic', 'asc')->get_where('prepared_forms', array('topic' => $this->input->post('prepared_topics')));
$new_form = $query->row_array();

Upvotes: 4

Valeh Hajiyev
Valeh Hajiyev

Reputation: 3246

$this->db->order_by("topic", "asc"); 
$query = $this->db->get_where('prepared_forms', array('topic' => $this->input->post('prepared_topics')));
$new_form = $query->row_array();

Upvotes: 2

GSto
GSto

Reputation: 42380

$this->db->select("*")
  ->from('prepared_forms')
  ->where('topic', $this->input->post('prepared_topics'))
  ->order_by('topic', 'asc')
  ->get()
  ->result_array();

Upvotes: 4

Related Questions