如何在codeigniter中使用order-by?

时间:2012-03-21 21:27:56

标签: codeigniter sql-order-by

我知道这很简单,但我没有完成它。

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

如何按主题名称(ASC)订购预先准备好的表单?

3 个答案:

答案 0 :(得分:4)

试试这个:

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

答案 1 :(得分:3)

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

答案 2 :(得分:2)

$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();