行爲不我看起來像這樣的兩個表:笨activerecords左加入如預期
Table_one
P_id Value
1001 50
1002 54
1003 47
1004 65
1005 51
Table_two
S_id Rating t_id
1001 1 1
1002 3 1
1001 5 2
1004 1 2
1005 2 2
我想加入使用CodeIgniter的Active Record類,這兩個表。這裏是我的代碼:
$tId = 1;
$this->db->select('Table_one.Value, Table_two.Rating');
$this->db->from('Table_one');
$this->db->join('Table_two', 'Table_one.P_id = Table_two.S_id', 'left');
$this->db->where('Table_two.t_id', $tId);
$query = $this->db->get();
我期待此查詢提供所有5行數據從表1中的值追加到前兩行的「等級」表2列。相反,我只從前兩行獲取數據。我如何重寫代碼,繼續使用活動記錄類來獲得我的預期結果?