Using a varible in a where clause
Using a varible in a where clause

Hi There,
I am trying to use a variable in my where clause:
->where( function ( $q ) {
$q
->where('primary_profile.nid', 39);
} )
I simply want to change 39 to be a variable but when I change 39 to:
->where( function ( $q ) {
$q
->where('primary_profile.nid', $nid);
} )
I get an error. I read a bit about SSP but the documentation makes no sense and there is no clear example. It seems this should be relativity straight forward but it has eaten up half a day. Can anyone let me know what I am missing or point me to a example that spells this put plainly.
Thanks in advance,
This discussion has been closed.
Replies
Yeah - this is PHP's werido closure syntax. Because they don't really do global variables you need to use the
use
statement:More about that in the PHP documentation.
Allan