# |
Sep 30th 2016, 17:37 |
inoas |
don't really understand the hasOne question |
# |
Sep 30th 2016, 17:37 |
inoas |
documents(id, revision_id), elements(id, revision_id) documents BTM elements ON document_id, document_revision_id, element_id |
# |
Sep 30th 2016, 17:37 |
wouter0100 |
Is there any way to create 2 hasOne's to eachother, but 1 could be to another table? For example, a Subscription has one Product1 or Product2. And Product1 has one Subscription and Product2 has one Subscription? How to implement this the right way? |
# |
Sep 30th 2016, 17:36 |
inoas |
We could use in an asymmetrical BTM assoc |
# |
Sep 30th 2016, 17:35 |
inoas |
Question: Would targetBindingKey for belongsToMany be a good idea? |
# |
Sep 30th 2016, 17:35 |
inoas |
today we learned alot about crud and the orm in our office - cause we had to ;) |
# |
Sep 30th 2016, 17:34 |
inoas |
I really don't like for instance the cakephp time stuff having traits mixing static and non static, maybe even abstract and non abstract functions |
# |
Sep 30th 2016, 17:34 |
inoas |
I'd just be careful with traits |
# |
Sep 30th 2016, 17:34 |
inoas |
even then you can create classes instead of traits @ attaching them... but only via the callbacks basically |
# |
Sep 30th 2016, 17:33 |
watermark |
thanks for the input |
# |
Sep 30th 2016, 17:33 |
inoas |
but behaviors come with loading multiple files |
# |
Sep 30th 2016, 17:33 |
inoas |
well I don't really know tbh |
# |
Sep 30th 2016, 17:33 |
hmic |
and if you need/want to attach them to very different kind of classes too (like a controller *and* a table, think of configtrait or logtrait) |
# |
Sep 30th 2016, 17:33 |
inoas |
yes traits are faster |
# |
Sep 30th 2016, 17:33 |
watermark |
I assumed traits would be faster and didn't see any reason to favor a behavior (in most cases) |
# |
Sep 30th 2016, 17:32 |
inoas |
share a function across two classes that already inherit from different classes etc |
# |
Sep 30th 2016, 17:32 |
hmic |
as mixins, like inoas said, they are good too |
# |
Sep 30th 2016, 17:32 |
hmic |
so for very simple things, it might be a trait |
# |
Sep 30th 2016, 17:32 |
inoas |
I like to use them when I want multiple inheritance |
# |
Sep 30th 2016, 17:32 |
hmic |
watermark, traits are "smaller" usually. less overhead |
# |
Sep 30th 2016, 17:32 |
inoas |
personally i have to say, omit traits whereever possible |
# |
Sep 30th 2016, 17:31 |
watermark |
Opinion time. When either a trait or behavior will work, should I always favor using a trait? |
# |
Sep 30th 2016, 16:44 |
ndm |
http://book.cakephp.org/3.0/en/orm/associations.html#belongstomany-associations (see `saveStrategy`) |
# |
Sep 30th 2016, 16:43 |
ndm |
http://book.cakephp.org/3.0/en/orm/saving-data.html#unlink-many-to-many-records |
# |
Sep 30th 2016, 16:43 |
ndm |
@str use the associations `ulink()` method, or the save replace save strategy and set the property to an empty array |
# |
Sep 30th 2016, 16:42 |
inoas |
is there a reason there is no targetBindingKey for belongsToMany? |
# |
Sep 30th 2016, 16:36 |
str |
Didn't work :( |
# |
Sep 30th 2016, 16:36 |
str |
$this->Users->save($user); |
# |
Sep 30th 2016, 16:36 |
str |
unset($user->partners[0]); |
# |
Sep 30th 2016, 16:11 |
str |
Neon1024, I tried the unset, and got: Call to undefined method App\Model\Entity\User::unset() |
# |
Sep 30th 2016, 15:36 |
Neon1024 |
!tias |
# |
Sep 30th 2016, 15:23 |
birdy247 |
would it return a row if the placement had been softDeleted |
# |
Sep 30th 2016, 15:23 |
birdy247 |
if I were to do $this->Timetables->find()->innerJoinWith('Placements) |
# |
Sep 30th 2016, 15:23 |
birdy247 |
lets say a placement that hasMany timetables |
# |
Sep 30th 2016, 15:22 |
birdy247 |
and I have soft Deleted a record |
# |
Sep 30th 2016, 15:22 |
birdy247 |
but If I am using the trash plugin |
# |
Sep 30th 2016, 15:22 |
birdy247 |
This might be an easy answer |
# |
Sep 30th 2016, 15:22 |
birdy247 |
Neon1024 |
# |
Sep 30th 2016, 15:20 |
str |
$user->unset('partner')->save(); or just the unset? |
# |
Sep 30th 2016, 15:20 |
Neon1024 |
$user->unset(â??partnerâ??) |
# |
Sep 30th 2016, 15:20 |
Neon1024 |
Of it one is set |