codeigniter でユニオンを実行しようとしています。このコードのスケルトンを別の場所で見つけました。
$this->db->select('title, content, date');
$this->db->from('mytable');
$query = $this->db->get();
$subQuery1 = $this->db->_compile_select();
$this->db->_reset_select();
// #2 SubQueries no.2 -------------------------------------------
$this->db->select('title, content, date');
$this->db->from('mytable2');
$query = $this->db->get();
$subQuery2 = $this->db->_compile_select();
$this->db->_reset_select();
// #3 Union with Simple Manual Queries --------------------------
$this->db->query("select * from ($subQuery1 UNION $subQuery2) as unionTable");
// #3 (alternative) Union with another Active Record ------------
$this->db->from("($subQuery1 UNION $subQuery2)");
$this->db->get();
私を混乱させているのは、元のサブクエリに get_where 句があると言うのですが、それをどのように含めるのですか? このようなもの:
クエリ 1
$this->db->select('Id,title, content, date');
$this->db->from('mytable');
$query = $this->db->get_where('Boo', array('Id' => $foo['foo_Id']);
$subQuery1 = $this->db->_compile_select();
クエリ 2
$this->db->select('title, content, date');
$this->db->from('mytable2');
$query = $this->db->get_where('Boo', array('Title' => $foo['foo_Title'])
$subQuery2 = $this->db->_compile_select();
ありがとうございました。