# |
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 |
# |
Nov 14th 2017, 16:38 |
diego182 |
https://pastebin.com/gftTnv3V |
# |
Nov 14th 2017, 16:38 |
inoas |
I don't think there is a difference between where and andWhere aside that latter stops the joining via orWhere |
# |
Nov 14th 2017, 16:36 |
diego182 |
https://pastebin.com/fC36hVRn |
# |
Nov 14th 2017, 16:35 |
inoas |
bascially it must match tags including sql LIKE (so CakePHP% or Chapter-%) |
# |
Nov 14th 2017, 16:34 |
inoas |
I considered stuff like subquery + count comparison... - but the subquery must also include all the other conditions |
# |
Nov 14th 2017, 16:33 |
diego182 |
hold on |
# |
Nov 14th 2017, 16:32 |
inoas |
diego182 and how would that example work if you wanted articles that matched to Tag CakePHP AND to Tag ORM? |
# |
Nov 14th 2017, 16:30 |
diego182 |
just consider the fallowing "As this function will create an INNER JOIN, you might want to consider calling distinct on the find query as you might get duplicate rows if your conditions don’t exclude them already. This might be the case, for example, when the same users comments more than once on a single article." |
# |
Nov 14th 2017, 16:28 |
diego182 |
theres an example just like you need |
# |
Nov 14th 2017, 16:27 |
diego182 |
https://book.cakephp.org/3.0/en/orm/retrieving-data-and-resultsets.html#filtering-by-associated-data-via-matching-and-joins |