Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 2 years ago.
0

You can't just insert the SQL, you need to escape it. Something like:

   orderBy(DB::raw(ABS(DATEDIFF('auction.start_date', NOW()))))->
0

That gives me a error

Call to undefined function DATEDIFF()

The funny thing is when I did

      orderBy(ABS(DATEDIFF('auction.start_date', NOW())))->

I didn't get an error, it just didn't load

0
Solution

How about

orderBy(DB::raw('ABS(DATEDIFF(auction.start_date, NOW()))'))->

Add quotes around everything going into DB::raw and remove the quotes around auction.start_date... should work fingers crossed.

Last updated 9 years ago.
0

That's it, thank you!!

0

Sign in to participate in this thread!

Eventy

Your banner here too?

ErichNiem erichniem Joined 30 Jul 2015

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.