二次開發(fā),數(shù)據(jù)關(guān)聯(lián)查詢優(yōu)化。
如下,第一種查詢方式太麻煩了吧, 有沒有快捷方便的辦法。類似
// 接收url傳遞的值
$sq_weixin = dr_safe_replace(\Phpcmf\Service::L('input')->post('jat2'));
//查詢1.需要優(yōu)化
$sqlx = "select a.*,a.id as sqid,b.id,b.name,b.thumb
from dr_1_shouquan as a left join dr_1_share_category as b on a.catid=b.id
where a.jat2='{$sq_weixin}' order by b.id desc";
$rowx = \Phpcmf\Service::M()->db->query($sqlx)->getResultArray();
//查詢方法2:參考模型方法. 教程實例,但是這個是美元實現(xiàn)關(guān)聯(lián)查詢
$row = \Phpcmf\Service::M()->table("1_shouquan")->where('jat2', $sq_weixin)->getAll();