Questions about laravel association queries?

clipboard.png

clipboard.png

course id = record cid, uid id

,

foreach ,

clipboard.png

the code is as follows

$course = DB::table("course")->get();
foreach ($course as $key => $value) {
    $value->recording = DB::table("record")->where("cid", $value->id)->get();
}

I would like to ask how to implement an ordinary relational query without using Eloquent ORM (I use laravel version 5.1 )

Please give me some advice. Thank you very much

Dec.08,2021

< H2 > verified content. < / H2 > The previous code did not take into account that DB returns an array rather than an Collection instance, which makes some methods unavailable. Secondly, it is not noticed in the first method that it requires two parameters, key,value. Only one parameter was given before.

   

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3b2b3-2c266.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3b2b3-2c266.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?