圖1是表1,圖2是表2.表1中的 advantage 對應表2的 type ,以及圖2的 with_id 對應表1的主鍵ID,也就是說,最終獲取出來的數據是這種格式:array( "id" => 1, "title" => "string", "content" => "string", "advantage" => array(6), "features" => array(4), "process" => array(7));用join寫獲取出來的數據就搞不懂該怎么去遍歷了。$res = ServiceList::alias("s") -> field("s.*") -> join("service_in_arr si", "s.id = si.with_id") -> field("si.title as title1, si.content as content1") -> select();這種寫出來的數據即圖3,表1僅1條數據,表2的數據僅是表1某字段的一個數據集。若我需要按照第一種格式去獲取數據,這種該怎么寫?請大神蒞臨指導,非常感謝!表1獲取的格式<code>array( "id" => 1,"title" => "string","content" => "string","advantage" => "advantage","features" => "features","process" => "process");</code>表2獲取的格式<code>array( "id" => 1,"with_id" => "string","type" => "string","title" => "string",);</code>需要的格式<code>array( "id" => 1,"title" => "string","content" => "string","advantage" => array(6),"features" => array(4),"process" => array(7));</code>
- 2 回答
- 0 關注
- 1772 瀏覽
添加回答
舉報
0/150
提交
取消