php - Complicated condition of getting from database

I want get line_id from my lines_stations table:
This is timetable search so I have from form station_from_id and station_to_id.
My search function is here:
public function search($station_from_id, $station_to_id) {
$stations = array($station_from_id, $station_to_id);
$this->db->from('lines_stations');
$this->db->where_in('station_id', $stations);
$q = $this->db->get();
$lines_stations = $q->result();
return $q->result();
}
This return me all row from lines_stations where station_id is station_from_id or station_to_id but I need get only these where order is correctly - for example:
- station_from_id = 2
- station_to_id = 1
I should get only this:
I haven't idea how to do this.
I'm using CodeIgniter 3.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: git was not found in your path, skipping source download
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.