Неправильное имя столбцов в codeigniter с помощью UNION Я выполняю строку поиска.
Это моя модель:
<?php
class Datacomplete extends CI_Model{
public function GetRow($keyword) {
$this->db->select('collg_name,state,country');
$this->db->from('tbl_college');
$this->db->like("collg_name",$keyword);
$this->db->or_like('state',$keyword);
$this->db->or_like('country',$keyword);
$query1 = $this->db->get_compiled_select();
$this->db->select('course_offrd_name,category_name,subcategory_name');
$this->db->from('tbl_course_offered');
$this->db->like("course_offrd_name",$keyword);
$this->db->or_like('category_name',$keyword);
$this->db->or_like('subcategory_name',$keyword);
$query2 = $this->db->get_compiled_select();
$result = $this->db->query($query1." UNION ".$query2);
return $result->result();
}
}
Это мой код JSON:
[{"collg_name":"college0","state":"Uttarpradesh","country":"India "},{"collg_name":"college1","state":"Karnataka","country":"India"},{"collg_name":"college2","state":"Maharastra","country":"india"},{"collg_name":"college3","state":"madhyapradesh","country":"india"},{"collg_name":"college4","state":"Rajasthan","country":"India"},{"collg_name":"college5","state":"Uttarpradesh","country":"India"},{"collg_name":"bsc","state":"Science","country":"UG"},{"collg_name":"Bachelor in Mechanical","state":"Engineering","country":"UG"},{"collg_name":"Bachelor in Mechanical","state":"Enginnering","country":"PG"},{"collg_name":"bsc","state":"Science","country":"PG"}]
здесь в данных от избранных я получаю правильные данные, но от избранных я не получаю правильные выходные данные.
[{"collg_name":"college0","state":"Uttarpradesh","country":"India "},
{"collg_name":"college1","state":"Karnataka","country":"India"},
{"collg_name":"college2","state":"Maharastra","country":"india"},
{"collg_name":"college3","state":"madhyapradesh","country":"india"},
{"collg_name":"college4","state":"Rajasthan","country":"India"},
{"collg_name":"college5","state":"Uttarpradesh","country":"India"},
, но со второго выбора я получаю неправильные данные
{"collg_name":"bsc","state":"Science","country":"UG"},
{"collg_name":"Bachelor in Mechanical","state":"Engineering","country":"UG"},
{"collg_name":"Bachelor in Mechanical","state":"Enginnering","country":"PG"},
{"collg_name":"bsc","state":"Science","country":"PG"}]
Фактические данные второго выбора должны быть
{"course_offrd_name ":"bsc","category_name":"Science","subcategory_name":"UG"},
{"course_offrd_name":"Bachelor in Mechanical","category_name":"Engineering","subcategory_name":"UG"},
{"course_offrd_name ":"Bachelor in Mechanical","category_name":"Enginnering","subcategory_name":"PG"},
{"course_offrd_name ":"bsc","category_name":"Science","subcategory_name":"PG"}]
В чем проблема в коде?Я делаю поиск по 2 таблицам с 3 столбцами из 1 таблицы и 3 столбцами из другой таблицы.
Для этого я использую UNION между двумя таблицами.но вывод не правильный.второй выбор не дает правильное имя столбца из модели, как решить проблему в коде?