Tried to make sort ordering db using codeigniter

Viewed 31

I Tried of making sort of names using Codeigniter but I found a problem, Please help me

Here is my data

  1. Doe Blablabla
  2. blablalba doe blablabla
  3. blablabla doe
  4. doe

I wanna sort it becomes like below but with some limit

  1. doe
  2. doe blablabla
  3. blablabla doe blablala
  4. blablabla doe

And here's my code, but the sort won't work yet

public function getFilter($name)
  {
$this->db->select("*, (CASE people
    WHEN people = '$name' THEN 1
    WHEN people LIKE '$name%' THEN 2
        ELSE 3
    END) as people_name");
    $this->db->from('citizen');
    $this->db->like('people', $id);
    $this->db->order_by("people_name asc");
    $this->db->limit(2);  
    return $this->db->get()->result();
  }
0 Answers
Related