# |
Nov 14th 2017, 17:07 |
inoas |
just use where(['or' => $yourConditions]) for the most part |
# |
Nov 14th 2017, 17:07 |
inoas |
so it is dangerous to use IMHO |
# |
Nov 14th 2017, 17:06 |
inoas |
diego182 well orWhere can have its uses but as far as I know it basically sets the query object into a state to append addition statements as OR instead of AND |
# |
Nov 14th 2017, 17:06 |
inoas |
was it _or()? |
# |
Nov 14th 2017, 17:06 |
diego182 |
i saw something about it, i guess were at github, that orWhere is comming back, aboud andWhere, i didnt now about that, thanks! |
# |
Nov 14th 2017, 17:06 |
inoas |
which will fail as the keys are not unique |
# |
Nov 14th 2017, 17:06 |
inoas |
now next problem I want to iterate this multiple times $orConditions['Devices.identifier LIKE'] = $value; |
# |
Nov 14th 2017, 17:02 |
inoas |
well not sure if it will stay deprecated, btu you should not - as you were suggesting to use andWhere I just wanted to warn you about orWhere |
# |
Nov 14th 2017, 17:02 |
inoas |
ah wrong channel |
# |
Nov 14th 2017, 17:02 |
inoas |
doing this WHERE a.id IN ( <select article id values related to tag 'parrot'> ) AND a.id IN ( <select article id values related to tag 'bungie'> ) (found here https://stackoverflow.com/questions/24519215/mysql-match-all-tags-rather-than-any/24519276#24519276 ) |
# |
Nov 14th 2017, 17:01 |
diego182 |
not anymore, as its been deprecated |
# |
Nov 14th 2017, 17:00 |
inoas |
btw, are you using orWhere? |
# |
Nov 14th 2017, 17:00 |
inoas |
diego182 |
# |
Nov 14th 2017, 16:56 |
inoas |
it rocks for mixing and matching AND and OR |
# |
Nov 14th 2017, 16:56 |
inoas |
I wish I could easily create an ebay-like search syntax |
# |
Nov 14th 2017, 16:54 |
inoas |
this is how it works https://gist.github.com/inoas/368c0931066033493255f01fb8835a39 |
# |
Nov 14th 2017, 16:50 |
diego182 |
humm |
# |
Nov 14th 2017, 16:49 |
inoas |
the matchings collapse into one innerJoin and an AND statement to concat the conditions |
# |
Nov 14th 2017, 16:49 |
diego182 |
i'm not shure if that would work, but what if you call two matching on query builder? |
# |
Nov 14th 2017, 16:47 |
inoas |
if I create a subquery each time heh |
# |
Nov 14th 2017, 16:46 |
inoas |
sounds it is easily doable |
# |
Nov 14th 2017, 16:46 |
inoas |
WHERE a.id IN ( <select article id values related to tag 'parrot'> ) AND a.id IN ( <select article id values related to tag 'bungie'> ) |
# |
Nov 14th 2017, 16:44 |
inoas |
lorenzo do you have pointers for best practise: Fetch Article matching 2 tags (AND not OR)? |
# |
Nov 14th 2017, 16:44 |
inoas |
but it merges based on assoc name |
# |
Nov 14th 2017, 16:44 |
inoas |
basically using foreach + innerJoinWith (that's like matching without getting data) |
# |
Nov 14th 2017, 16:43 |
inoas |
I have tried the upper already without digging around |
# |
Nov 14th 2017, 16:43 |
inoas |
here is some sql solutions https://stackoverflow.com/a/24519276 |
# |
Nov 14th 2017, 16:42 |
inoas |
I want to fetch an article that has at least those 2 tags assigned |
# |
Nov 14th 2017, 16:42 |
inoas |
but it merges them together "Intelligently" ;) |
# |
Nov 14th 2017, 16:42 |
inoas |
I tried multiple innerJoins |
# |
Nov 14th 2017, 16:42 |
diego182 |
humm, you want it to have exclusively one of the tags? |
# |
Nov 14th 2017, 16:41 |
inoas |
so as long as there is one tag matching it will work |
# |
Nov 14th 2017, 16:41 |
inoas |
but it will also get articles that match either or |
# |
Nov 14th 2017, 16:41 |
inoas |
yes that will get that list |
# |
Nov 14th 2017, 16:40 |
diego182 |
https://pastebin.com/ntcp7x4d |
# |
Nov 14th 2017, 16:39 |
inoas |
as I said, probably count distinct subquery or something |
# |
Nov 14th 2017, 16:39 |
diego182 |
thats true |
# |
Nov 14th 2017, 16:39 |
diego182 |
humm |
# |
Nov 14th 2017, 16:39 |
inoas |
name cannot be CakePHP AND Chapter at the same time |
# |
Nov 14th 2017, 16:39 |
inoas |
but that's not going to work as that can never be true |
# |
Nov 14th 2017, 16:38 |
inoas |
yeah I am using it like that @ like |