Forums

Unknown Column in Where Clause

hangbill 12 Jun, 2019
Hi
Trying to add a search function to a connectivity table. Table opens fine in front end. But search returns a 1054. Debug does not work, in my example get messg unknown column 'members' in 'where clause'. Have not set any conditions.

Found Twincarbs post Feb 2018 and followed the instructions.
Tried to upload images but seems cant.

Events
index
{fn:member}
{view:search}
{view:member_list}

Views
member_list => data provider => {var.member}
Columns list
members.name:Name
member_misc_fields.company:Company
member_misc_fields.city:City
member_misc_fields.occupation:Occupation
member_misc_fields.email:Email
member_misc_fields.telephone:Telephone
member_misc_fields.extension:Extension

Views
search

Functions
member
Two models, related => members and member_misc_fields.
Then in the member model under searchable fields
members.name
member_misc_fields.company
member_misc_fields.city
member_misc_fields.occupation


Thanks
healyhatman 12 Jun, 2019
Instead of using "searchable fields" put them in the where conditions, set to "continue" if null. You might want to have them as LIKE %{data:fieldname}% instead of = depending on the type of field and your requirements.
hangbill 12 Jun, 2019
Thanks, will try this.
What is the "searchable fields" used for ?
hangbill 12 Jun, 2019
Still get same error Unknown column 'members.' in 'where clause'.
Members is the model name.
I notice that the related model add_member_fields does not have where conditions, searchable fields etc. Wonder if my prob has something to do with the related table. Because I need to set search terms on the related table too.
healyhatman 12 Jun, 2019
In the where conditions you would put model.fieldname

Screenshot of your read data action if possible please. Searchable fields are for...... No idea I never use them.
hangbill 12 Jun, 2019
Can't send png images, 20kb, get "error saving the attachment file" messg. Tried different browsers, same story.

OK now in the Where Condition, reading left to right have members.name LIKE %{data:name}% Continue
No error messg but search does not return any result. The whole table remains visible.
Have a huge debug. It starts ... will it help to see all?
Array
(
    [conn] => directory
    [keywords] => br
    [0d4e14f532d92632bd557daf62d88643] => c13c6e3e1fdbac5bbab181782ba397b8
    [joomla_user_state] => logged_in
    [c42234b300a2feaffea15712e4c1305d] => eadd9a9138c0e53d9c7f3dd8de87f5b2
    [Itemid] => 2087
    [option] => com_chronoconnectivity6
    [view] => connection
)
healyhatman 12 Jun, 2019
I use snag.gy , and you can put the URL in.

And from looking at that debug, it's doesn't include "name". So your 'name' field data isn't being sent. Make sure it's inside the form element.
hangbill 12 Jun, 2019
Thanks for Snaggy
https://snag.gy/qrFopA.jpg
https://snag.gy/fy48Pl.jpg

There is no form. Using Connectivity to reflect a selection of Joomla User fields, including some related User data.
The members model is linked the Joomla Users table and does include a name field
healyhatman 12 Jun, 2019
Yes but your name field needs to be inside a form element, otherwise your web page doesn't know it needs to send the data from the field anywhere. In CC in views there is a "form" element. Put one of those submitting to index and put your field inside it.
hangbill 12 Jun, 2019
This is how I set up Views, not working. Is this what you mean?
https://snag.gy/feHnx8.jpg
https://snag.gy/AmYSix.jpg
healyhatman 12 Jun, 2019
No it's not.



You need a FORM AREA that your field goes in. And use a text field instead of a search field.
hangbill 13 Jun, 2019
Think I figured what searchable fields does in the functions tab - seems it sets the fields that will be searched. This is useful.

Now have a search bar per your guide, ie text field and button. And a form area. Not sure what form area is, seems it is not visible. Still have to figure how to configure it to submit to index. I've tried putting the table url in the Action URL and/or parameters but this does not work. Thing is I dont want to specify a particular field any more. Rather let user search for name, city, company etc and then let the field list in the searchable fields function return the appropriate records.

Is this possibe? How to configure the form area ?
https://snag.gy/ohLp6U.jpg
https://snag.gy/wdj8Ym.jpg
healyhatman 13 Jun, 2019
Submit Event should be index, action URL should be empty. My bad.

Your read data action, your search field values goes in your WHERE CONDITIONS, set to Continue if null. Like this (ignore the fields set to STOP)

This way, it only filters according to your search values if you've actually entered them.
hangbill 13 Jun, 2019
Please see images. Seems the Send button is not triggering index.

Also
tried the solution posted by TwinCarb at
http://www.chronoengine.com/forums/posts/t105003 but cant get that to
work either. Doing a search should not be this difficult. Major challenge with deficient documentation ... .

Thanks Healyhatman

https://snag.gy/EMlk5A.jpg
https://snag.gy/Kxw1Ne.jpg
https://snag.gy/u8fNno.jpg
healyhatman 13 Jun, 2019
Should be LIKE %{data:name}% if you want to get the search term anywhere in the field instead of matching the whole thing only.

And I can't see the rest of your form area but is the button inside it too? And your read data is the one that is run in the index?
hangbill 13 Jun, 2019
OK added the % .
Not sure if the button is inside the form area. What is a form area? See pic of Views => 4 elements ie member_list, form3, search_field and search_submit_button. Is this correct? Not sure how to get the button into the form area.

My scrolling thing wont capture whole form area page but see pic of the missing lower bit.

Yes the read data is run from index, it's called by {fn:member}

https://snag.gy/CJLqcs.jpg
https://snag.gy/uD2XRZ.jpg
https://snag.gy/X901FV.jpg
https://snag.gy/MIGOSQ.jpg
healyhatman 13 Jun, 2019
See that form3 thing in your second picture? That's the form area and your search field and button needs to be in the Content part of that.
hangbill 13 Jun, 2019
So are the Views incorrect then, should not have search_field and search_submit_button ?
Or is it correct and I have to call them with html or php from the content box ? Not sure how to do this eg <input type="submit" value="Submit"> does not work.
healyhatman 13 Jun, 2019
put your {view:}'s inside that form area.
hangbill 13 Jun, 2019
Still not sending to index, and now placing some literals on top of the search bar



Just not getting it. Follow your guides and also random different stuff but ... like pullin' teeth
Thoughts?
hangbill 13 Jun, 2019
Careless, thanks.
Getting closer I think. Search does not have any impact on the full table list but debug shows an index event and the keyword and nothing in the button.
Also noted when I place the where conditions that you mentioned the complete list is not shown. Must be some SQL thing going on. Separating the conditions with OR seems to return all records

https://snag.gy/z1Qnpa.jpg
healyhatman 13 Jun, 2019
So your field is still called 'text4' in the form data (that's why there are two "name" fields in the setup for your text field. One is the {view} name, the other is the form data name. Rename it as well, and make sure you have your Where conditions set up properly
hangbill 13 Jun, 2019
Presume names need not be the same?
See pic of the Where conditions

https://snag.gy/65OBnZ.jpg
https://snag.gy/bMPgN5.jpg
healyhatman 13 Jun, 2019
Your form data name is "search" so it would need to be {data:search} in that particular case.
hangbill 13 Jun, 2019
OK so {data:search} inside the form data provider ?

On submit this is being sent /members/member-directory?conn=directory&event=index.

So seems the search term is not sent
healyhatman 13 Jun, 2019
No? In the where conditions.
hangbill 13 Jun, 2019
Got it. Yes!!
What a struggle for me, and serious thanks to you.

A question before my next challenge.
Is there a way to send the submit by pressing Enter in the search bar?


https://snag.gy/rtvjcb.jpg
healyhatman 13 Jun, 2019
It should just work as usual, nothing special should need to be done. Semantic UI forma automatically submit on enter. If not you can force it with jquery
hangbill 14 Jun, 2019
Thanks Healyhatman,
Cheers
hangbill 17 Jun, 2019
Need help again please.
Must have changed a setting, now the send button not sending anything to index. Have tried different things around for hours, no solution yet.

So this is current setup.

In the form area, have 2 content entries => the text field search name and the send button name. Have tried the field names and the data names. So currently the content box has {view:search} and {view:search_button}. These are the view names (the top names). The submit event is index. Have nothing in data provider but previously tried {data:search}.

In the functions conditions model.name Like %{data:search}%.

But I can see it won't work because there is no url at bottom of page when mousing over the send button.
Array
(
[0d4e14f532d92632bd557daf62d88643] => f824af00518f00c45a64fae9afcca93c
[c42234b300a2feaffea15712e4c1305d] => edb6b3079cf87c95b197d8670480b72e
[f66fe6972ca6c494f948822edfbb4402] => c1a8b15738633986a6af922a70fbf6ac
[5bde71c6705273816e428a1fa58e57d9] => f1d5e3cfd6b223968f9c33574821551d
[joomla_user_state] => logged_in
[Itemid] => 2087
[option] => com_chronoconnectivity6
[view] => connection
)
healyhatman 17 Jun, 2019
The URL at the bottom would only show up if the send button was a LINK, but it's not it's a SUBMIT BUTTON. The URL it is sending the data to is the 'action="....."' tag in the form element.

If your fields are inside the FORM, and you are calling the FORM in your index event instead of the individual fields then it should be working.
hangbill 17 Jun, 2019
OK, was not calling the form in index. Done, thanks
Still not working, think it might be the where condition. So the table field name is model.name. Then Like, then %{data:search}%, then Continue
Array
(
    [conn] => memberdirectory
    [event] => index
    [searchmember] => ciu
    [searchbutton] => 
    [0d4e14f532d92632bd557daf62d88643] => f824af00518f00c45a64fae9afcca93c
    [c42234b300a2feaffea15712e4c1305d] => edb6b3079cf87c95b197d8670480b72e
    [f66fe6972ca6c494f948822edfbb4402] => c1a8b15738633986a6af922a70fbf6ac
    [5bde71c6705273816e428a1fa58e57d9] => f1d5e3cfd6b223968f9c33574821551d
    [joomla_user_state] => logged_in
    [Itemid] => 2087
    [option] => com_chronoconnectivity6
    [view] => connection
)
healyhatman 17 Jun, 2019
Look at your debug there mate. Your field's data name appears to be "searchmember". Same issue you had 5 posts ago.
hangbill 17 Jun, 2019
Bloody hell.
OK so the where condition name has to match the search field data name - works, thanks Healyhatman.
And added a field from the related model, separated by OR and it works too.
Thanks for your help man ... .
This topic is locked and no more replies can be posted.