# |
Sep 12th 2019, 14:28 |
ricksaccous |
I'm guessing it's just the unorthodox structure that causes unlink to fail but i don't really know |
# |
Sep 12th 2019, 14:26 |
jbcharron |
Yeah. I actually had to migrate the code from join table using TableA and TableB PKs to the slug one, and I tried to figure out a solution allowing me not to change the whole controllers code, which used the link() and unlink() function. And as the link() still worked, I was wondering why the unlink() didn't. But I guess I will have to try out a different solution :P |
# |
Sep 12th 2019, 14:24 |
ricksaccous |
and you could maybe have a flag for latest tag you update in app logic as well, sounds like a pain |
# |
Sep 12th 2019, 14:23 |
ricksaccous |
then you'd achieve the same thing |
# |
Sep 12th 2019, 14:23 |
jbcharron |
yep, that's the idea, a many have many. For example, my ObjectA has 3 versions, I link it with tags (using the slug, so my tags are linked to all the object versions), so if I delete the last version of my object, the versions 1 and 2 of my object don't lose the link to the tags |
# |
Sep 12th 2019, 14:23 |
ricksaccous |
one thing you could do is post/preprocess records from slugs to records if you really want |
# |
Sep 12th 2019, 14:22 |
ricksaccous |
hmmm |
# |
Sep 12th 2019, 14:21 |
ricksaccous |
in this case i don't think joindata makes sense |
# |
Sep 12th 2019, 14:20 |
ricksaccous |
many have many |
# |
Sep 12th 2019, 14:20 |
ricksaccous |
i mean |
# |
Sep 12th 2019, 14:20 |
ricksaccous |
but using both pks you could still say one has many, but i suppose you want to relate them to subsets |
# |
Sep 12th 2019, 14:20 |
ricksaccous |
maybe i'm missing something |
# |
Sep 12th 2019, 14:19 |
ricksaccous |
that seems unecessary |
# |
Sep 12th 2019, 14:15 |
jbcharron |
And so, the versions share the same Tags (which is the purpose of my join table) |
# |
Sep 12th 2019, 14:15 |
jbcharron |
Actually, no :( this is a model containing many versions of the same business object, the versions 1 to N share the same slug |
# |
Sep 12th 2019, 14:09 |
ricksaccous |
are slugs not unique? |
# |
Sep 12th 2019, 14:09 |
ricksaccous |
how is it a hasMany to TableB |
# |
Sep 12th 2019, 14:07 |
slackebot |
too. Thanks in advance :slightly_smiling_face: |
# |
Sep 12th 2019, 14:07 |
slackebot |
`link()` function works well, but the `unlink()` gets nothing in the `_joinData` property, and try to unlink using my `TableB` primary key value in my join table foreign key field, which is not linked to the primary key of TableB. I don't know if I explained this issue in a clear way, but I don't understand why the link() works and not the unlink(). They don't follow the exact same process, but I expect that if one works, the other one should work |
# |
Sep 12th 2019, 14:07 |
jbcharron |
Hi there, I am struggling with `unlink()` in a `belongsToMany` association. I have a join table using `TableA_id` and `TableB_slug` as foreign keys to `TableA` and `TableB`, where `TableA.id` is a primary key, and `TableB.slug` is not. So basically my join table is linked to `TableA` with a `belongsTo`, and `TableB` with `hasMany`. TableA and TableB are linked to each other with `belongsToMany` through my join table. My issue is that the |
# |
Sep 12th 2019, 13:30 |
ricksaccous |
wew |
# |
Sep 12th 2019, 13:30 |
ricksaccous |
do you chelas/gents get together and do shrimp on the barbie? |
# |
Sep 12th 2019, 13:03 |
admad |
by "db table" i meant your actual database table where you can set column defaults |
# |
Sep 12th 2019, 13:02 |
kailas |
where in the table? is there some callback on new entity? |
# |
Sep 12th 2019, 12:57 |
alice |
https://www.meetup.com/Brisbane-CakePHP-Meetup-Group/ |
# |
Sep 12th 2019, 12:57 |
alice |
For friends in Brisbane, would love to see you join our meet up group : ) |
# |
Sep 12th 2019, 12:56 |
alice |
Hello from Australia :flag-au: |
# |
Sep 12th 2019, 12:23 |
felix.robaglia |
1st option is enough for me, thanks again :slightly_smiling_face: |
# |
Sep 12th 2019, 12:03 |
conehead |
I personally prefer the first option as you can cleary see how many levels deep you go. With the third option you can add more limitations |
# |
Sep 12th 2019, 12:00 |
felix.robaglia |
I prefer the first one you mentioned, maybe the 2nd one is better for readability though ? :slightly_smiling_face: |
# |
Sep 12th 2019, 11:58 |
conehead |
There are 2 other ways as well. `'Contracts.Users', 'Contracts.Sources'` Or `'contain' => ['Contracts' => function (Query $q) { return $q->contain(['Users]); } |
# |
Sep 12th 2019, 11:56 |
felix.robaglia |
works perfectly, thanks @conehead. |
# |
Sep 12th 2019, 11:53 |
conehead |
``` $this->paginate = [ 'contain' => ['Contracts' => ['Users', 'Sources']] ]; ``` |
# |
Sep 12th 2019, 11:52 |
felix.robaglia |
i want to do something like this : ``` $this->paginate = [ 'contain' => ['Contracts' => contain('Users, 'Sources')] ]; ``` |
# |
Sep 12th 2019, 11:51 |
felix.robaglia |
But each of my contracts contain a User and a Source, how do I "nest" contains ? |
# |
Sep 12th 2019, 11:50 |
felix.robaglia |
Hello, I have the following assocation in my index method: ```$this->paginate = [ 'contain' => ['Contracts'] ];``` |
# |
Sep 12th 2019, 11:49 |
valerij.bancer |
Hi, how to execute `SELECT DISTINCT ...` in 3.x without using `GROUP BY` that is generated by `distinct()` method? |
# |
Sep 12th 2019, 11:22 |
fhxfhx |
k tx |
# |
Sep 12th 2019, 11:21 |
conehead |
But this doesn't have to mean that the config is not overridden somewhere else (although it shouldn't). And it depends on the plugin if it has a db config |
# |
Sep 12th 2019, 11:17 |
spriz |
before jumping into real life code |
# |
Sep 12th 2019, 11:17 |
spriz |
I would go through this tutorial if I were you: https://book.cakephp.org/3.0/en/tutorials-and-examples/cms/installation.html |