0
$table = 'favorite_contents';
$contents = DB::table($table)
        ->join('contents', function($join) use($table){
            $join->on("$table.content_id", '=', 'contents.id');
        })
        ->whereIn("$table.content_id",$ids)
        ->update(array(
                "$table.expired" => 1,
                "$table.type" => "contents.type"
        ));

The "$table.expired" => 1 is working fine, but the "$table.type" => "contents.type" doesn't.

So the problem has something to do with getting the value of type in the contents table, how do I do this without resorting to foreach?

Laurence
  • 58,936
  • 21
  • 171
  • 212
Bryan P
  • 4,142
  • 5
  • 41
  • 60

1 Answers1

0

Change "$table.type" => "contents.type" to "$table.type" => DB::raw("contents.type"). As you have it, I believe the update() method is trying to save the string "contents.type" rather than getting the "type" column from "contents". If you're using MySQL and the favorite_contents.type is numeric column, it might convert "contents.type" to 0 without showing an error.

jchamberlain
  • 1,038
  • 8
  • 26