0

I'm using a Laravel 8 for website developement, and on the next part of code, I execute a query:

$assig = DB::table('table')
->where('table.column', '=', "oneValue")
->select('anfunctionOnDatabase(2,table.columDesc)')
->get();

but it no works.

How I need call to database function on laravel?

Thanks

1
  • if you want to use functions of the database then you should use raw db for laravel Commented Apr 4, 2022 at 9:27

2 Answers 2

2

Use selectRaw()

like this;

$assig = DB::table('table')
    ->where('table.column', '=', "oneValue")
    ->selectRaw('anfunctionOnDatabase(2,table.columDesc)')
    ->get();
Sign up to request clarification or add additional context in comments.

Comments

1

Use : DB::raw :

$assig = DB::table('table')
->where('table.column', '=', "oneValue")
->select(DB::raw("anfunctionOnDatabase(2,table.columDesc)"))
->get();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.