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

Closures has there own local scope they dont see outer variables try using

function($query) use($dato)
{

}
Last updated 2 years ago.
0

Alright!, yes, scope issue is clear.one second let me try sorry I did not see your solution thank you

usm4n said:

Closures has there own local scope they dont see outer variables try using

function($query) use($dato)
{

}
Last updated 2 years ago.
0

I think whereRaw should be like this:

 ->whereRaw('id_specialty = ?', $dato);
Last updated 2 years ago.
0

that solved the scope issue! wonderful god bless you!; I though have syntax error at here

'id_specialty', '=', $dato)

unexpected T_VARIABLE

I have tried all possible combinations of the single quotes, to no result so far

Last updated 2 years ago.
0

Problem is in your whereRaw see my previous answer!

Last updated 2 years ago.
0

usm4n said:

I think whereRaw should be like this:

->whereRaw('id_specialty = ?', $dato);

:)

Last updated 2 years ago.
0

"Argument 2 passed to Illuminate\Database\Query\Builder::whereRaw() must be an array, string given,

but if I write "specialiation_id = 7'

it works, it works if I hardcode a digit there, and if I echo $dato is certainly is 7 why would not take $dato if it is equal to 7?

Last updated 2 years ago.
0

don't want to quote again :) already posted the solution try to scroll up this page :)

Last updated 2 years ago.
0

but I have copied and pasted the ->whereRaw('id_specialty = ?', $dato); when I said I had the syntax issue meant after pasting your whereinRaw

Last updated 2 years ago.
0

The second argument needs to be an array, just like the error message say.

->whereRaw('id_specialty = ?', [$dato]);
Last updated 2 years ago.
0
Solution

Sorry my bad :( try

 ->whereRaw('id_specialty = ?',array( $dato));

this should solve the problem.

Last updated 2 years ago.
0

:( beaten by @Marwelln with a 5 second difference trophy goes to him!

Last updated 2 years ago.
0

Yes! it did and now, my god, how should I do both of you have been essential to the solution of the problem: Usm4m provided the critical use($dato) explaining that the closure have their own scope, and you solved the syntax. How can I give the solution to both ? You absolutely both deserve it.

Last updated 2 years ago.
0

Usm4n, both deserve it so we can do the following. I ll post whatever trivial question right now, you answer it and I upthumb it, we are not cheating both of you legitimately deserve it if the System is imperfect I have to bypass it. Shall we do that?

usm4n said:

:( beaten by @Marwelln with a 5 second difference trophy goes to him!

I give you the solution because your sytax was also correct but I absolutely want to give the solution to Marwell, so I will ask him if it is fine that I post whatever easy stuff and right away I will upthumb it. I just hate to be in the situation where two persons deserve the same merit and they limit me to one, it is not fair, so it needs to be bypassed.

Last updated 2 years ago.
0

Gotta watch Arrow season 2... We'll do it some other time, kuddos to @Marwelln he won, no worries i am happy you found your solution. Regards!

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

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.