Buy Now
Sign in

Search all the attribute values of all the elements

shiluba , December 02 2019, 20:58
shiluba 39
December 02 2019, 20:58 #390206
I am trying to get a search form to work on a sub-model.
The main table called "elements" is loaded by the main model called "elem".
The sub-table called "attributes" is loaded by the sub-model called "attr". This model is set with the Relation : "Multiple matching records, foreign key in this table." The searched keywords are to be found into the "value" column of the "attributes" table.
When I try this condition (under the Where conditions of "elem") ...

... I get this error : 1054 Unknown column 'attr.value' in 'where clause'.

Does anyone know if what I'm trying is doable with CCv6 ?
Thanks in advance for your advices

healyhatman 9
December 03 2019, 09:51 #390212
I don't think what you're trying to do is doable in CCv6 or even just in MySQL. You have to include every column.
Web developer at - I DO NOT work for ChronoEngine!
Professional Work:
Custom CF / CC Plugins and Extensions:
shiluba 39
December 04 2019, 10:48 #390224
I managed to do it by turning the "attr" sub-model into the main model of another Read data called "search_attributes" and loaded before the main Read data.
"search_attributes" is set with ...
- Select type : Return an array of key/values ...
- No page limit
- Where condition : attr.value ... LIKE ... %{data:keywords}% ... Null value : Continue
- Fields to retrieve : elem_id (= foreign key matching with the id columns of the "elements" table)

Then, into the main Read data, I added this where condition : ... IN ... {var:search_attributes} ... Null value : continue

And that's it. The main Read data gets filtered according to the search results based on all the values of the "attributes" table.