我有一个非常大的查询:
SELECT *
FROM cont_contracting
LEFT OUTER JOIN contacts_cont_contracting_1_c l1_1 ON cont_contracting.id=l1_1.contacts_cont_contracting_1cont_contracting_idb AND l1_1.deleted=0
LEFT OUTER JOIN contacts l1 ON l1.id=l1_1.contacts_cont_contracting_1contacts_ida AND l1.deleted=0
LEFT OUTER JOIN contacts_contacts_12_c l2_1 ON l1.id=l2_1.contacts_contacts_12contacts_ida AND l2_1.deleted=0
LEFT OUTER JOIN contacts l2 ON l2.id=l2_1.contacts_contacts_12contacts_idb AND l2.deleted=0
LEFT OUTER JOIN contacts_contacts_1_c l3_1 ON l1.id=l3_1.contacts_contacts_1contacts_ida AND l3_1.deleted=0
LEFT OUTER JOIN contacts l3 ON l3.id=l3_1.contacts_contacts_1contacts_idb AND l3.deleted=0
LEFT OUTER JOIN contacts_contacts_2_c l4_1 ON l1.id=l4_1.contacts_contacts_2contacts_ida AND l4_1.deleted=0
LEFT OUTER JOIN contacts l4 ON l4.id=l4_1.contacts_contacts_2contacts_idb AND l4.deleted=0
LEFT OUTER JOIN contacts_contacts_4_c l5_1 ON l1.id=l5_1.contacts_contacts_4contacts_ida AND l5_1.deleted=0
LEFT OUTER JOIN contacts l5 ON l5.id=l5_1.contacts_contacts_4contacts_idb AND l5.deleted=0
LEFT OUTER JOIN contacts_contacts_5_c l6_1 ON l1.id=l6_1.contacts_contacts_5contacts_ida AND l6_1.deleted=0
LEFT OUTER JOIN contacts l6 ON l6.id=l6_1.contacts_contacts_5contacts_idb AND l6.deleted=0
LEFT JOIN huge__insurance_carriers_cont_contracting_1_c l7_1 ON cont_contracting.id=l7_1.huge__insurance_carriers_cont_contracting_1cont_contracting_idb AND l7_1.deleted=0
LEFT JOIN huge__insurance_carriers l7 ON l7.id=l7_1.huge__insucae9arriers_ida AND l7.deleted=0
LEFT JOIN cont_contracting_cstm cont_contracting_cstm ON cont_contracting.id = cont_contracting_cstm.id_c
WHERE (((l1.id='b8a00721-40f1-7801-b4b9-50ce152ce2ec'
) OR (l2.id='b8a00721-40f1-7801-b4b9-50ce152ce2ec'
) OR (l3.id='b8a00721-40f1-7801-b4b9-50ce152ce2ec'
) OR (l4.id='b8a00721-40f1-7801-b4b9-50ce152ce2ec'
) OR (l5.id='b8a00721-40f1-7801-b4b9-50ce152ce2ec'
) OR (l6.id='b8a00721-40f1-7801-b4b9-50ce152ce2ec'
)))
我一直在尝试使用Laravel的查询构建器进行转换,这是我提出的但仍未获取数据的原因:
$appts = DB::table('cont_contracting')
->leftJoin('contacts_cont_contracting_1_c as l1_1', 'cont_contracting.id', '=', 'l1_1.contacts_cont_contracting_1cont_contracting_idb')
->leftJoin('contacts as l1', 'l1.id', '=', 'l1_1.contacts_cont_contracting_1contacts_ida')
->leftJoin('contacts_contacts_12_c as l2_1', 'l1.id', '=', 'l2_1.contacts_contacts_12contacts_ida')
->leftJoin('contacts as l2', 'l2.id', '=', 'l2_1.contacts_contacts_12contacts_idb')
->leftJoin('contacts_contacts_1_c as l3_1', 'l1.id', '=', 'l3_1.contacts_contacts_1contacts_ida')
->leftJoin('contacts as l3', 'l3.id', '=', 'l3_1.contacts_contacts_1contacts_idb')
->leftJoin('contacts_contacts_2_c as l4_1', 'l1.id', '=', 'l4_1.contacts_contacts_2contacts_ida')
->leftJoin('contacts as l4', 'l4.id', '=', 'l4_1.contacts_contacts_2contacts_idb')
->leftJoin('contacts_contacts_4_c as l5_1', 'l1.id', '=', 'l5_1.contacts_contacts_4contacts_ida')
->leftJoin('contacts as l5', 'l5.id', '=', 'l5_1.contacts_contacts_4contacts_idb')
->leftJoin('contacts_contacts_5_c as l6_1', 'l1.id', '=', 'l6_1.contacts_contacts_5contacts_ida')
->leftJoin('contacts as l6', 'l6.id', '=', 'l6_1.contacts_contacts_5contacts_idb')
->leftJoin('huge__insurance_carriers_cont_contracting_1_c as l7_1', 'cont_contracting.id', '=', 'l7_1.huge__insurance_carriers_cont_contracting_1cont_contracting_idb')
->leftJoin('huge__insurance_carriers as l7', 'l7.id', '=', 'l7_1.huge__insucae9arriers_ida')
->leftJoin('cont_contracting_cstm as cont_contracting_cstm', 'cont_contracting.id', '=', 'cont_contracting_cstm.id_c')
->where(function($query) {
$query->orWhere('l1.id', '=', Session::get('id'))
->orWhere('l2.id', '=', Session::get('id'))
->orWhere('l3.id', '=', Session::get('id'))
->orWhere('l4.id', '=', Session::get('id'))
->orWhere('l5.id', '=', Session::get('id'))
->orWhere('l6.id', '=', Session::get('id'));
})
->get();
我做错了什么导致Laravel查询无法正确获取记录?
我已经多次检查过文档并且没有看到问题。
由于