jrCore_db_search_items parameter issue

JamBoy
JamBoy
@ashiksh
10 years ago
13 posts
I have user defined fields profile_latitude and profile_longitude in profile table

I need search the records those have profile_latitude and profile_longitude.

Query:

$_params = array(

'exclude_jrUser_keys' => true,
'exclude_jrProfile_keys' => true,
'pagebreak' => 100
);
$_params['search'][]= 'profile_latitude != ""';

$_rs = jrCore_db_search_items('jrProfile',$_params);

For some reason its returning error. How can i pass value is not equal to null(!='') in this search parameter.Here my latitude or longitude values may be -ve numbers too.

Thanks in advance!

updated by @ashiksh: 12/02/14 09:05:49AM
paul
@paul
10 years ago
4,332 posts
I've often run into the same issue!!
Basically, jrCore_db_search_items cannot test the state of items that are not on the datastore in the first place.
You'll need to somehow make sure that there is a profile_latitude field for all profiles, even if it's empty.


--
Paul Asher - JR Developer and System Import Specialist
brian
@brian
10 years ago
10,148 posts
paul:
I've often run into the same issue!!
Basically, jrCore_db_search_items cannot test the state of items that are not on the datastore in the first place.
You'll need to somehow make sure that there is a profile_latitude field for all profiles, even if it's empty.

Actually this isn't true any longer (as of the 5.2 core). If you use either of the "not" searches - i.e.

!=
not_like

It will include items that do NOT have the key set (since they of course "match"). The problem here is that you're searching for an empty string, which is NOT going to work (since jrCore_db_search_items expects at minimum 3 parts to a search parameter).

for this you want to use a not_like search - i.e.

$_params['search'][] = 'profile_latitude not_like ?%'

That says "get me profile_latitude entries where the value is NOT 1 or more characters".

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
JamBoy
JamBoy
@ashiksh
10 years ago
13 posts
'profile_latitude not_like ?%'

This is not working for what i need. I need to get all records that has no empty field.

ie: 'profile_latitude not equal to empty'

Waiting for a quick solution!
brian
@brian
10 years ago
10,148 posts
JamBoy:
This is not working for what i need. I need to get all records that has no empty field.

Then it's the opposite:

$_params['search'][] = 'profile_latitude like ?%''

This says get all records that have a profile_latitude key that is at LEAST 1 character.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net

Tags