# |
Apr 26th 2021, 10:04 |
rightscoreanalysis |
perfectamente - thanks! |
# |
Apr 26th 2021, 09:54 |
noel |
@rightscoreanalysis https://book.cakephp.org/migrations/3/en/index.html |
# |
Apr 26th 2021, 09:52 |
rightscoreanalysis |
Does Cake have took to keep track of database changes. In Magento for example any changes to db structure can added to a script and a db table tracks the current version and will execute any updates if the version is outdated, is there a similar tool for Cake? |
# |
Apr 26th 2021, 09:36 |
noel |
I’ve taken the plunge and raised an issue: https://github.com/cakephp/cakephp/issues/15466 |
# |
Apr 26th 2021, 09:26 |
noel |
The reason I think it is a bug is that the original association `$this->belongsTo(‘Notaries’, [‘className’ => ‘People’, ‘foreignKey’ => ‘notary_id’]); ` works if I add a `person_id` field to `enquiries` table. It shouldn’t need that, I don’t think. |
# |
Apr 26th 2021, 09:22 |
slackebot |
@dereuromark @corey.taylor.fl? |
# |
Apr 26th 2021, 09:22 |
noel |
It does do so if I don’t alias the foreignKey, so in other words if I do this: ```$this->belongsTo('Notaries', ['className' => 'People', 'foreignKey' => 'person_id']);``` Then it recognises the association and lists is in `PeopleTable->_associations` but it doesn’t work if I set a custom foreignKey. I think this might be a bug in the ORM but I’d like an expert opinion before I create an issue on GitHub @admad or |
# |
Apr 26th 2021, 09:20 |
neon1024 |
Good point! That’s me out of ideas :) |
# |
Apr 26th 2021, 09:19 |
noel |
So it should set this association on the PeopleTable, but it doesn’t. |
# |
Apr 26th 2021, 09:19 |
noel |
from this: `className' => 'People'` – that’s what makes it an alias. |
# |
Apr 26th 2021, 09:18 |
neon1024 |
As if ‘Notaries’ isn’t in the Registry, I wonder how Cake would know what table that it |
# |
Apr 26th 2021, 09:17 |
neon1024 |
Although, I might be barking up the wrong tree! |
# |
Apr 26th 2021, 09:17 |
neon1024 |
Might be worth looking in the TableRegistry to see what keys exist? |
# |
Apr 26th 2021, 09:16 |
neon1024 |
Yep, probably. My brain was over here https://github.com/cakephp/cakephp/blob/3.9.9/src/ORM/Table.php#L240 |
# |
Apr 26th 2021, 09:15 |
noel |
```$this->belongsTo('Notaries', ['className' => 'People', 'foreignKey' => 'notary_id']);``` |
# |
Apr 26th 2021, 09:14 |
noel |
As far as I can tell, that’s precisely what I’m doing. |
# |
Apr 26th 2021, 09:14 |
neon1024 |
Just thinking you might want to alias People as Notaries :) |
# |
Apr 26th 2021, 09:13 |
neon1024 |
Haha, fair enough. To be honest, I don’t use CakePHP much these days and I’m still on 3.9 :) |
# |
Apr 26th 2021, 09:13 |
noel |
You’ve lost me now. |
# |
Apr 26th 2021, 09:13 |
neon1024 |
Well you can alias a table class |
# |
Apr 26th 2021, 09:12 |
noel |
No.. `belongsTo` |
# |
Apr 26th 2021, 09:12 |
neon1024 |
Maybe, I thought you had `belongsToMany` |
# |
Apr 26th 2021, 09:12 |
noel |
What does that mean? |
# |
Apr 26th 2021, 09:12 |
neon1024 |
Maybe it needs a specific alias? |
# |
Apr 26th 2021, 09:12 |
noel |
It’s a manyToOne – can’t be inversed as I understand it. |
# |
Apr 26th 2021, 09:11 |
neon1024 |
Perhaps it needs to be inversed? Do you have an association in PeopleTable? |
# |
Apr 26th 2021, 09:11 |
noel |
No warnings |
# |
Apr 26th 2021, 09:11 |
neon1024 |
`Cake\ORM\Table` instance instead of concrete? |
# |
Apr 26th 2021, 09:11 |
neon1024 |
Do you get a warning about ` |
# |
Apr 26th 2021, 09:10 |
noel |
I think so… it returns a query object anyway. |
# |
Apr 26th 2021, 09:08 |
neon1024 |
Can you traverse the association? `$this->Enquiries->Notaries->find()` ? |
# |
Apr 26th 2021, 09:07 |
noel |
In concrete terms. I have `people` and `enquiries` tables. I’m trying to set up a relationship between the two via the following association on the `enquiries` table: ```$this->belongsTo('Notaries', ['className' => 'People', 'foreignKey' => 'notary_id']);``` However if I then grab the PeopleTable instance and look at the `_associations` property, `enquiries` is not listed as an associated table. |
# |
Apr 26th 2021, 09:06 |
neon1024 |
My first guess would be a typo :) |
# |
Apr 26th 2021, 09:02 |
noel |
Hi all. I’m having trouble with associations. The issue is that if I try to create a manyToOne association with a custom name and an aliased foreignKey, that association does not get listed in $table->_associations. |
# |
Apr 26th 2021, 09:02 |
neon1024 |
Yeah, okay, thanks. I’ll keep hunting in the docs and do some testing on my docker db instance :) |
# |
Apr 26th 2021, 09:01 |
noel |
@neon1024 mm… that doesn’t sound right no. I might be wrong but my understanding of lock means that it is locked by a process, so that only that process can use the table. Which means inserts that are part of that transaction can happen but any queries (INSERT or otherwise) that are not part of that transaction cannot happen. |
# |
Apr 26th 2021, 09:00 |
neon1024 |
Ah right, thanks! So if I am running a transaction, no inserts can happen right? |
# |
Apr 26th 2021, 08:58 |
noel |
Yes |
# |
Apr 26th 2021, 08:56 |
neon1024 |
Do transaction queries lock db tables? |
# |
Apr 26th 2021, 03:56 |
admad |
@turkles https://github.com/itosho/easy-query#bulk-upsert |
# |
Apr 26th 2021, 02:26 |
slackebot |
save_or_update maybe? (up to 10k entries in a go.. though..) |