मुझे एक टेबल से जानकारी चाहिए और यदि किसी अन्य तालिका से मिलान की गई जानकारी भी है।लैरावेल के साथ एक बाएं बाहरी कैसे जुड़ें?
यह मेरा कोड
$scoreObject = DB::table('responses')
->select('responses.id', 'responses.questions_id', 'responses.answer_id', 'responses.open_answer', 'responses.user_id', 'responses.scan_id',
'questions.question', 'questions.question_nr', 'questions.type', 'questions.totalsection_id',
'answers.id as answerID', 'answers.answer', 'answers.questions_id', 'answers.points'
)
->Join('answers as answers', 'responses.answer_id', '=', 'answers.id')
->Join('questions as questions', 'answers.questions_id', '=', 'questions.id')
->orderBy('questions.id', 'ASC')
->where('responses.scan_id', $scanid)
->where('responses.user_id', $userid)
->groupBy('questions.id')
->get();
यह सब प्रतिक्रियाओं है कि जवाब के साथ मैचों (answers.questions_id questions.id ') देता है। कुछ प्रतिक्रियाएं मेल नहीं खाती हैं (क्योंकि कोई प्रतिक्रिया नहीं है .answer_id) लेकिन मैं अभी भी प्रतिक्रियाओं की जानकारी चाहता हूं।
मुझे लार्वेल में इतनी बाएं बाहरी शामिल कैसे मिल सकती है?
आप एक ** बाईं बाहरी में शामिल होने जा रहा है के रूप में शामिल निर्दिष्ट करने की कोशिश कर सकते **: '-> शामिल हों ('उत्तर के रूप में जवाब', 'respondes.answer_id', '=', 'answer.id', 'left left')'। 'Join' विधि का अंतिम (वैकल्पिक) पैरामीटर' $ type' है, जो निर्दिष्ट नहीं होने पर, 'आंतरिक' मान को डिफ़ॉल्ट करता है। – Bogdan
@ बोगदान यह काम करना चाहिए। इसे एक उत्तर के रूप में लिखें;) – lukasgeiter
@ बोगदान, वास्तव में यह काम करता है! यदि आप इसे उत्तर के रूप में रखते हैं तो मैं इसे सही के रूप में चिह्नित कर सकता हूं। अजीब है कि यह बेहतर दस्तावेज नहीं है http://laravel.com/docs/4.2/queries#joins। –