0
私はこのコードCodeIgniterのget_whereとORDER_BY
これを持っている。これは私のモデル
function get_where_custom($col, $value) {
$table = $this->get_table();
$this->db->where($col, $value);
$query=$this->db->get($table);
return $query;
}
ある
function menu()
{
$data['query'] = $this->get_where_custom('key', 'value');
$data['view_file'] = 'menu';
$this->load->view($data);
}
function get_where_custom($col, $value)
{
$this->load->model('mdl_menu');
$query = $this->mdl_menu->get_where_custom($col, $value);
return $query;
}
私のコントローラである私は、列名date_posted
を持つテーブルに値を示していますデータベース。テーブルをdate_posted
で注文したい。私はこれにどうやってアプローチするのですか?
ありがとうございました。以下のようなモデルを使用$this->db->order_by('column_name');
で
あなたは** "get_where_custom" **関数の内部**ます$ this-> DB-> ORDER_BY($のCOL)を追加することができます。** $ COLをdate_postedとして想定する。 –