# |
Apr 26th 2019, 18:17 |
ricksaccous |
it has a conditions option |
# |
Apr 26th 2019, 18:17 |
ricksaccous |
without using a finder |
# |
Apr 26th 2019, 18:17 |
ricksaccous |
you could use conditions to define the association |
# |
Apr 26th 2019, 18:17 |
jnguyen |
bascially to filter out some data |
# |
Apr 26th 2019, 18:16 |
jnguyen |
yeah |
# |
Apr 26th 2019, 18:16 |
ricksaccous |
are you using a finder because there are conditions? |
# |
Apr 26th 2019, 18:16 |
jnguyen |
hmmm |
# |
Apr 26th 2019, 18:16 |
ricksaccous |
do a join instead? |
# |
Apr 26th 2019, 18:16 |
jnguyen |
is there* |
# |
Apr 26th 2019, 18:16 |
jnguyen |
is any work around? |
# |
Apr 26th 2019, 18:15 |
jnguyen |
ah ok |
# |
Apr 26th 2019, 18:15 |
ricksaccous |
okay yeah i think that's where the problem is |
# |
Apr 26th 2019, 18:15 |
jnguyen |
yes |
# |
Apr 26th 2019, 18:15 |
ricksaccous |
@jnguyen? |
# |
Apr 26th 2019, 18:14 |
ricksaccous |
is the custom finder being used to define an association in this case? |
# |
Apr 26th 2019, 18:12 |
ricksaccous |
hmmmm |
# |
Apr 26th 2019, 18:12 |
ricksaccous |
there is somewhere in the book about limitations on pagination when using custom finders |
# |
Apr 26th 2019, 18:11 |
jnguyen |
ah ok so I can't use sortWhiteList if I use a custom finder? |
# |
Apr 26th 2019, 18:11 |
ricksaccous |
yeah that's the limitations of custom finders with pagination |
# |
Apr 26th 2019, 18:10 |
jnguyen |
Hey guys, so I have a problem when I use the pagination component , when I use a custom finder I'm not able to sort the data |
# |
Apr 26th 2019, 15:09 |
hollistergraham123 |
So right now I set the view var by doing $this->set([‘var’ => $var, ‘_serialize’ => ‘var’]); I am assuming your saying do some sort of getmethod $this->set([‘_serialize’ => array_merge($this->getViewVar(), ‘user’)]); |
# |
Apr 26th 2019, 15:07 |
admad |
and it's not a "function", just an array |
# |
Apr 26th 2019, 15:06 |
admad |
so merge instead of overwriting |
# |
Apr 26th 2019, 15:05 |
hollistergraham123 |
Is there a way to push variables to the _serialize function. I.e. I want to always send back the logged in user data along with whatever the individual controller function sends. I put the serialize function in Appcontroller on the beforeRender event to serialize the user var but it is overriding what got serialize in the controller method. |
# |
Apr 26th 2019, 15:00 |
dereuromark |
you can only lose/delete data if you store additional fields in your pivot table. but fair enough :slightly_smiling_face: |
# |
Apr 26th 2019, 14:59 |
hollistergraham123 |
Good point |
# |
Apr 26th 2019, 14:57 |
dereuromark |
it is important to not call this delete, as no records on the both sides should be removed (or people think they might). |
# |
Apr 26th 2019, 14:56 |
hollistergraham123 |
Thank you! I swear I looked through all of the delete documentation before asking! |
# |
Apr 26th 2019, 14:56 |
admad |
yup unlink() is the way then |
# |
Apr 26th 2019, 14:56 |
dereuromark |
I just remembered that I used that for tags module. |
# |
Apr 26th 2019, 14:56 |
dereuromark |
https://book.cakephp.org/3.0/en/orm/saving-data.html#unlink-many-to-many-records :slightly_smiling_face: |
# |
Apr 26th 2019, 14:55 |
admad |
ah, miread |
# |
Apr 26th 2019, 14:55 |
dereuromark |
I think he wants to keep both sides, though. |
# |
Apr 26th 2019, 14:55 |
admad |
dont need to do anything explicitly |
# |
Apr 26th 2019, 14:54 |
admad |
join table records are automatically deleted if a primary table record is deleted |
# |
Apr 26th 2019, 14:54 |
dereuromark |
isnt there even unlink() or sth? |
# |
Apr 26th 2019, 14:53 |
dereuromark |
Simplest solution is to work on this pivot table directly, ->delete($entity) or deleteAll( with conditions) |
# |
Apr 26th 2019, 14:52 |
hollistergraham123 |
How do I delete just a relationship in cakephp. In my use case I have users with many to many relationship with stores. If I just want to remove a user from that store. How can I just delete the join record? |
# |
Apr 26th 2019, 13:55 |
hippo |
:thumbsup: trying to track down the issue now.. Just thought I'd mention it in here as well! |
# |
Apr 26th 2019, 13:54 |
dereuromark |
otherwise you can open a ticket with a detailed report on how to reproduce. |
# |
Apr 26th 2019, 13:54 |
dereuromark |
hippo: if you can trace down the issue, maybe you can open a PR to fix things. |