# |
Jan 6th 2020, 17:22 |
ckjksl |
I'm having a bit of trouble with a simple "toxi" tag solution. This is where there are three tables, `assets`, `tags`, and `assettags`, which contains `asset_id` and `tag_id` as a lookup. I've tried a couple of ways, but the part that's failing for me is `'saveStrategy' => 'replace'` |
# |
Jan 6th 2020, 16:43 |
ricksaccous |
but that would be too hard to explain to you, heh |
# |
Jan 6th 2020, 16:43 |
ricksaccous |
you can also do an inner join and then directly search on the field |
# |
Jan 6th 2020, 16:42 |
ricksaccous |
if you want them in the match then just do something similar but do $this->Matches->find()->where(['Matches.id' => $id])->contain(['SeasonPlayers' => function ($q) |
# |
Jan 6th 2020, 16:42 |
ricksaccous |
$seasonPlayerEntities = $this->Matches->SeasonPlayers->find(['SeasonPlayers.club_id' => $matchEntity->field_name])->toArray(); |
# |
Jan 6th 2020, 16:40 |
gianmarxgagliardi |
I would like to compare the underlined fields in order to take only the players who are associated with a certain id and not all the players |
# |
Jan 6th 2020, 16:40 |
ricksaccous |
whatever you can just do this $matchEntity = $this->Matches->get($id); |
# |
Jan 6th 2020, 16:39 |
ricksaccous |
just id? |
# |
Jan 6th 2020, 16:39 |
ricksaccous |
of Matches |
# |
Jan 6th 2020, 16:39 |
ricksaccous |
what is the primary key |
# |
Jan 6th 2020, 16:39 |
slackebot |
<gianmarxgagliardi> |
# |
Jan 6th 2020, 16:38 |
ricksaccous |
it's related to the Matches.home_id ? |
# |
Jan 6th 2020, 16:38 |
ricksaccous |
but it isn't related to id huh |
# |
Jan 6th 2020, 16:38 |
ricksaccous |
ohhh |
# |
Jan 6th 2020, 16:37 |
ricksaccous |
$matchEntity = $this->Matches->find()->matching('SeasonsPlayers', function ($query) use ($id) { return $query->where(['SeasonsPlayers.club_id' => $id]); })->contain(['Foo','Bar']); |
# |
Jan 6th 2020, 16:37 |
gianmarxgagliardi |
it gives me an empty set |
# |
Jan 6th 2020, 16:36 |
gianmarxgagliardi |
it gives me the whole empty |
# |
Jan 6th 2020, 16:36 |
ricksaccous |
replace where with matching i already told you |
# |
Jan 6th 2020, 16:35 |
gianmarxgagliardi |
```$matchHome1 = $this->Matches->find('all') ->where(['MatchPlayers.SeasonPlayers.club_id' => $matchHome->club_home_id]) ->contain(['SeasonReferees','SeasonReferees.Referees', 'ClubsHome', 'MatchPlayers','MatchPlayers.SeasonPlayers','MatchPlayers.SeasonPlayers.Players']);``` |
# |
Jan 6th 2020, 16:34 |
gianmarxgagliardi |
ok it turns but some problem |
# |
Jan 6th 2020, 16:27 |
ricksaccous |
i'll help |
# |
Jan 6th 2020, 16:27 |
ricksaccous |
read the thing and try to figure it out if you still have trouble after reading |
# |
Jan 6th 2020, 16:27 |
gianmarxgagliardi |
? |
# |
Jan 6th 2020, 16:27 |
gianmarxgagliardi |
how could I do |
# |
Jan 6th 2020, 16:23 |
ricksaccous |
etc |
# |
Jan 6th 2020, 16:23 |
ricksaccous |
->matching('SeasonPlayers', function ($q) |
# |
Jan 6th 2020, 16:23 |
ricksaccous |
you're right sorry |
# |
Jan 6th 2020, 16:23 |
ricksaccous |
and use matching |
# |
Jan 6th 2020, 16:23 |
ricksaccous |
actually you could keep what you have without the where |
# |
Jan 6th 2020, 16:22 |
ricksaccous |
read this |
# |
Jan 6th 2020, 16:22 |
ricksaccous |
https://book.cakephp.org/3/en/orm/retrieving-data-and-resultsets.html |
# |
Jan 6th 2020, 16:22 |
gianmarxgagliardi |
i have to compare club id |
# |
Jan 6th 2020, 16:21 |
ricksaccous |
i probably should not spoon feed you so much |
# |
Jan 6th 2020, 16:21 |
gianmarxgagliardi |
I do not understand |
# |
Jan 6th 2020, 16:21 |
ricksaccous |
Matches.id => $id |
# |
Jan 6th 2020, 16:21 |
ricksaccous |
and you set the where to be |
# |
Jan 6th 2020, 16:20 |
ricksaccous |
you keep the matching you had |
# |
Jan 6th 2020, 16:16 |
gianmarxgagliardi |
Unknown method "has" |
# |
Jan 6th 2020, 16:16 |
gianmarxgagliardi |
```$matchHome=$this->Matches->find() ->contain('SeasonReferees','SeasonReferees.Referees', 'ClubsHome', 'MatchPlayers','MatchPlayers.SeasonPlayers','MatchPlayers.SeasonPlayers.Players') ->where(['SeasonPlayers.club_id' => 3]);``` |
# |
Jan 6th 2020, 16:13 |
ricksaccous |
no not really you simply create a table class and set the table to the view and you should be fine |
# |
Jan 6th 2020, 16:12 |
luizcmarin |
* Any information about this in the manual? |