Wednesday, June 17, 2015

updateAll() and the need to load another class

Since I could not find an explanation in the documentation, I'm asking here.

I have two tables with an 1:n relationship and I'm trying to use updateAll() on the child but use a column of the parent in the condition.
For example the two tables look like this:
  • playlists
    • name
    • customer_id
  • playlist_pages
    • url
    • delay
    • playlist_id
Now I'm trying to do something like this:
TableRegistry::get('playlist_pages')->updateAll([
     
'delay' => 10
 
], [
     
'Playlists.customer_id' => 'some_id'
 
]

The error is "Unknown column 'Playlists.customer_id' in 'where clause'" which would mean, that the relationship is not detected and no join exists.
Is this syntax/idea supported by the updateAll function?

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: