Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 1 year ago.
0

Some further googling found two threads (one, two), but using DB::raw("NULL") gave the same results - I get zero in the DB instead of null.

Last updated 1 year ago.
0

Unfortunately I can confirm as well... I have no idea how possible to insert NULL with using conditional parameters.

My problem seem like this: [...]

:discountPrice,

. .

array( "discountPrice" => ($product->sale === true)?$product->discountPrice:"NULL",

. .

[...]

I've tried with DB:raw("NULL") as well but no luck...

Last updated 1 year ago.
0
Solution

ehh... I've found the solution... :)

array( "discountPrice" => ($product->sale === true)?$product->discountPrice:NULL,

So the NULL is need without quote sign.

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

jsvensson jsvensson Joined 13 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.