Passing a variable in a where clause
Passing a variable in a where clause
lougalli
Posts: 1Questions: 1Answers: 0
Trying to pass a variable to a where clause and continue to get JSON errors
This works fine -
->where( function ($q) {
$q->where( 'CONTACT_ID', 5 );
} )
This does not -
->where( function ($q) {
$q->where( 'CONTACT_ID', $varContactID );
} )
This discussion has been closed.
Answers
Well, you are not passing it in I am afraid. And I guess you can't. But you can use global PHP variables like $_SESSION ... Those will work.
This is how PHP antonymous functions work. You have to use the
use
statement to be able to access the parameter:See the PHP documentation for details.
I'll probably write an FAQ about this as it keeps coming up, even although its a PHP issue rather than specifically DataTables.
Allan