codeigniter order_by get code example
Example 1: codeigniter order by
$this->db->from($this->table_name);
$this->db->order_by("name", "asc");
$query = $this->db->get();
return $query->result();
Example 2: codeigniter select for update
$table = "my_table";
$id = 1;
$update = ["status"=>"working"];
$query = $this->db->select()
->from($table)
->where('id', $id)
->get_compiled_select();
$data = $this->db->query("$query FOR UPDATE")->row_array();
$this->db->where('id', $data['id'])->update($table,$update);