[SOLVED] CG User Directory Search (for all terms)
Posted: Wed Oct 05, 2011 3:32 pm
Hi
I am using FrontEndUsers 1.15.4
CGUserDirectory 1.2.6
on CMSMS 1.9.4.2
Using a search form for the users works fine if only one property is entered, or if "any" is selected. However, if you enter data on more than one field and select "all", no results are returned even if you know there should be matching data.
EG
I have a user with propvals first_name = John, last_name=Doe
Setting a search with John and Doe in the correct fields of the form returns nothing. Using the debug feature from the config file, I can see that the sql that is generated is:
SELECT COUNT(U.id)
FROM
cms_module_feusers_users U
LEFT JOIN cms_module_feusers_properties P
ON U.id = P.userid
WHERE
(P.title = 'last_name' AND P.data REGEXP 'Doe')
AND
(P.title = 'first_name' AND P.data REGEXP 'John')
LIMIT 1
In phpMyAdmin this returns nothing, though if you try just for John, or for Doe, you get results for the same user.
Is there something wrong with the SQL? (not my strong point).
Has anyone else got a multi input query to work?
Many thanks
Nik
ADDENDUM -
After playing around with the sql to get the result I figure the module is trying to get, I came up with this, by adding a join for each additional search parameter. - (not that I can use this in the module! nor solve the problem). Please correct me if this is all rubbish!
I'm just trying to figure out what the problem is.
SELECT COUNT(U.id)
FROM
cms_module_feusers_users U
LEFT JOIN cms_module_feusers_properties P
ON U.id = P.userid
LEFT JOIN cms_module_feusers_properties P2
ON U.id = P2.userid
WHERE
(P.title = 'last_name' AND P.data REGEXP 'Doe')
AND
(P2.title = 'first_name' AND P2.data REGEXP 'John')
LIMIT 1
I am using FrontEndUsers 1.15.4
CGUserDirectory 1.2.6
on CMSMS 1.9.4.2
Using a search form for the users works fine if only one property is entered, or if "any" is selected. However, if you enter data on more than one field and select "all", no results are returned even if you know there should be matching data.
EG
I have a user with propvals first_name = John, last_name=Doe
Setting a search with John and Doe in the correct fields of the form returns nothing. Using the debug feature from the config file, I can see that the sql that is generated is:
SELECT COUNT(U.id)
FROM
cms_module_feusers_users U
LEFT JOIN cms_module_feusers_properties P
ON U.id = P.userid
WHERE
(P.title = 'last_name' AND P.data REGEXP 'Doe')
AND
(P.title = 'first_name' AND P.data REGEXP 'John')
LIMIT 1
In phpMyAdmin this returns nothing, though if you try just for John, or for Doe, you get results for the same user.
Is there something wrong with the SQL? (not my strong point).
Has anyone else got a multi input query to work?
Many thanks
Nik
ADDENDUM -
After playing around with the sql to get the result I figure the module is trying to get, I came up with this, by adding a join for each additional search parameter. - (not that I can use this in the module! nor solve the problem). Please correct me if this is all rubbish!

SELECT COUNT(U.id)
FROM
cms_module_feusers_users U
LEFT JOIN cms_module_feusers_properties P
ON U.id = P.userid
LEFT JOIN cms_module_feusers_properties P2
ON U.id = P2.userid
WHERE
(P.title = 'last_name' AND P.data REGEXP 'Doe')
AND
(P2.title = 'first_name' AND P2.data REGEXP 'John')
LIMIT 1