title: Laravel DB update on primary keys works with a raw array but not with a variable
body: <p>I initially wanted to use Eloquent:</p>
  
  <pre><code>$product-&gt;quantity_discounts()
  -&gt;where('min_amount', $discount['min_amount'])
  -&gt;where('user_id', $discount['user_id'])
  -&gt;where('group_id', $discount['group_id'])
  -&gt;update($discount);
  </code></pre>
  
  <p>but Eloquent doesn't support composite primary keys (<a href="https://github.com/laravel/framework/issues/5355" rel="nofollow noreferrer">https://github.com/laravel/framework/issues/5355</a>).</p>
  
  <p>My code, using the query builder:</p>
  
  <pre><code>DB::table('quantity_discounts')
  -&gt;where('min_amount', $discount['min_amount'])
  -&gt;where('user_id', $discount['user_id'])
  -&gt;where('group_id', $discount['group_id'])
  -&gt;where('product_id', $id)
  -&gt;update($discount);
  </code></pre>
  
  <p>$discount:</p>
  
  <pre><code>[
      "min_amount" =&gt; "2",
      "price" =&gt; "20",
      "user_id" =&gt; "1",
      "group_id" =&gt; "0"
  ]
  </code></pre>
  
  <p>The only field that gets changed is the price. All the other fields are part of a primary key constraint.</p>
  
  <p><a href="https://i.stack.imgur.com/mgdj2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mgdj2.png" alt="enter image description here"></a></p>
  
  <p>However, passing <em>exactly</em> what's inside $discount works. It seems like the query builder won't mass assign values to primary keys. </p>
  
  <p>Query for <code>update($discount)</code>:</p>
  
  <pre><code>update `quantity_discounts` set `min_amount` = ?, `price` = ?, `user_id` = ?, `group_id` = ? where `min_amount` = ? and `user_id` = ? and `group_id` = ? and `product_id` = ?
  </code></pre>
  
  <p>Query for <code>update([...])</code>:</p>
  
  <pre><code>update `quantity_discounts` set `min_amount` = ?, `price` = ?, `user_id` = ?, `group_id` = ? where `min_amount` = ? and `user_id` = ? and `group_id` = ? and `product_id` = ? 
  </code></pre>
  
  <p>The queries are identical. The arrays are identical. [] works but $discount doesn't.</p>
  
  <p>If any primary key field is changed, the price won't be changed either. Nothing will be changed. If only price is changed, price will change.</p>
  
  <p><a href="https://i.stack.imgur.com/e1RGu.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e1RGu.gif" alt="enter image description here"></a></p>
  
  <p>Though using a raw array [] works:</p>
  
  <p><a href="https://i.stack.imgur.com/cS2d1.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cS2d1.gif" alt="enter image description here"></a></p>
  
  <p>And the arrays are indeed identical:</p>
  
  <p><a href="https://i.stack.imgur.com/ZiP9Q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZiP9Q.png" alt="enter image description here"></a></p>
  
  <p>Could this be some sort of mass assignment protection? <code>["min_amount" =&gt; $discount["min_amount"], ...]</code> didn't work either. I have set all fields to be $fillable, but that's for Eloquent, not the query builder.</p>