# |
Aug 26th 2016, 08:21 |
fquffio |
Uhmâ?¦ So I'd have to look up in some configuration array which inverse association corresponds to the association passed. |
# |
Aug 26th 2016, 08:21 |
lorenzo |
make it require Association and a some config describing what is possible |
# |
Aug 26th 2016, 08:20 |
fquffio |
I'm trying to do this with command pattern, as the app will soon start to become slightly complicated. I have a command `ListAssociated`, and I'd like it to basically need only the `Association` object (and the primary key of the object to find relationships for, of course). |
# |
Aug 26th 2016, 08:19 |
lorenzo |
and use that config, instead of building everything dynamically |
# |
Aug 26th 2016, 08:19 |
lorenzo |
have a place where you declare the allowed paths, and some meta information for the path it is allowed to be traversed |
# |
Aug 26th 2016, 08:19 |
lorenzo |
since you are not implementing a generic library, the add some configuration to it |
# |
Aug 26th 2016, 08:18 |
fquffio |
I know. :) |
# |
Aug 26th 2016, 08:18 |
lorenzo |
thatâ??s the problem with overly dynamic and generic code, it is difficult to build and get right. Whereas just implementing the specific use case you need is significantly easier |
# |
Aug 26th 2016, 08:18 |
fquffio |
@lorenzo: In many cases I could, but not always. For instance, `Posts` could be related to `Users` twice: `CreatedBy` and `ModifiedBy`. |
# |
Aug 26th 2016, 08:17 |
lorenzo |
and find the one you need? |
# |
Aug 26th 2016, 08:17 |
lorenzo |
canâ??t you iterate $table->associations() ? |
# |
Aug 26th 2016, 08:17 |
fquffio |
Uhm, well.. I'm basically implementing JSON API. I have and endpoint `/posts/1/relationships/foos` that should return a list of all entities linked to the post with ID=1. |
# |
Aug 26th 2016, 08:14 |
voycey |
generally if you have set up your ERD properly from the beginning it should all work pretty smoothly |
# |
Aug 26th 2016, 08:14 |
voycey |
Im sure you have a use case for it but I cant work out what it is, I dont think I have ever had to do what you are doing in a lot of years of using cake, saying that I could just be completely misunderstanding what you are trying to do |
# |
Aug 26th 2016, 08:12 |
slackebot |
association. But in my scenario, I only know the name of Posts->Comments association. |
# |
Aug 26th 2016, 08:12 |
fquffio |
Yeah, but in some cases the FK isn't in the target table. BelongsToMany associations have a joint table, that somehow needs to be added to the query in the JOIN clause in order to achieve the result. The `::matching()` method does exactly this: it adds conditions and joins (if needed) depending on the type of association you are dealing with. But in order to find Comments that are linked to a specific Post, you need to know the name of the Co |
# |
Aug 26th 2016, 08:08 |
voycey |
you can do conditional associations through the model layer already and you can build these on the fly if required |
# |
Aug 26th 2016, 08:08 |
voycey |
I dont really understand what you mean - the whole point of associations are that they are based off primary and foreign keys |
# |
Aug 26th 2016, 08:08 |
fquffio |
Also, conditional associations would need to be treated in a special manner, as I'd have to manually add the finder. |
# |
Aug 26th 2016, 08:07 |
fquffio |
@voycey First of all, thanks. :slightly_smiling_face: Well, your solution would work well for HasMany and HasOne associations. But I wish I could support _any_ type of association in a transparent way, thus I'd expect to interact with the `Association` object to act consistently. |
# |
Aug 26th 2016, 08:06 |
voycey |
$this->Comments->find |
# |
Aug 26th 2016, 08:06 |
voycey |
or sorry |
# |
Aug 26th 2016, 08:05 |
voycey |
? |
# |
Aug 26th 2016, 08:05 |
voycey |
why cant you just do $this->Posts->find()->where(['post_id' => $postId])->contain->(['Foo']) |
# |
Aug 26th 2016, 08:03 |
slackebot |
duplicating ORM logic. I have obtained an acceptable result calling `TableRegistry::get('Posts')->get($postId, ['contain' => ['Foo']])->get('foo')`, but this is an array of already hydrated entities, while I need to get the query object in order to paginate results. Thanks aforehand! |
# |
Aug 26th 2016, 08:03 |
slackebot |
Post. If I knew the name of the inverse association (`Bar`), that would be easily feasible using `TableRegistry::get('Comments')->find()->matching('Bar', function($q) { ... });`. Unfortunately, in this context I have no way of knowing the name of the inverse association. Is there any way of achieving the same result? I saw that `SelectableAssociationTrait::_buildQuery()` does pretty much the kind of thing I need, but it is a protected method, and I'd |
# |
Aug 26th 2016, 08:03 |
fquffio |
Hello everybody! Sorry to be obsessiveâ?¦ I asked this very same question yesterday, but I got no answer, so I'll have one last try. :) I have a table, say `Posts`, that is linked to a second table, say `Comments`, via an association named `Foo`. The inverse association (Comments -> Posts) potentially has a completely different name that doesn't follow any convention, say `Bar`. I need to obtain a Query object to find Comments that are rela |
# |
Aug 26th 2016, 07:55 |
birdy247 |
Morning :slightly_smiling_face: |
# |
Aug 26th 2016, 05:28 |
unorthodox |
Morning |
# |
Aug 26th 2016, 04:40 |
voycey |
Does anyone on here use Swagger? |
# |
Aug 26th 2016, 03:26 |
xuding |
@jeremyharris thanks |
# |
Aug 26th 2016, 03:07 |
jeremyharris |
@xuding you can invalidate the entity field like so: `$entity->errors(â??fieldnameâ??, â??error messageâ??);` (see: http://book.cakephp.org/3.0/en/orm/entities.html#validation-errors) |
# |
Aug 26th 2016, 02:58 |
xuding |
how do we manually invalidate form fields in Cake 3? |
# |
Aug 26th 2016, 02:57 |
xuding |
hi |
# |
Aug 26th 2016, 00:02 |
sinus |
eg: ``` 'redisForeverCache' => [ 'className' => 'Redis', 'duration' => '+1 year', 'host' => 'localhost', 'server' => '127.0.0.1', ], |
# |
Aug 26th 2016, 00:01 |
sinus |
```$ redis-cli 127.0.0.1:6379> exit ``` |
# |
Aug 26th 2016, 00:01 |
sinus |
I have Redis installed and also predis |
# |
Aug 26th 2016, 00:00 |
sinus |
I get `Cache engine Cake\Cache\Engine\RedisEngine is not properly configured.` |
# |
Aug 25th 2016, 23:59 |
sinus |
Hi, anyone used Redis as cache with Cake3? |
# |
Aug 25th 2016, 22:29 |
latbud |
Hey guys. I'm looking into CakePHP to add a small, custom ecommerce solution I'd build for a client's site. I'm wondering if there's any kind of PayPal integration plugin for CakePHP 3.x. I've been able to find them for 2.x but haven't had any luck with the current version. Thanks! |
# |
Aug 25th 2016, 22:26 |
nemmons |
my best guess is that it would just be inconvenient or difficult or perhaps impossible to pass that configuration option on to the Marshaller as well so that all of Marshaller's references to _joinData would be handled properly |