Search code examples
phpmodel-view-controllerormredbean

RedBean One to Many Attribute Not Working


Edit: rewriting my question

I have a one-many relation that sets files to a publication. It doesn't work as I expected, when I do:

var_dump($this->pub->xownFiles);
R::store($this->pub);
var_dump($this->pub->xownFiles);

The first var_dump gives me:

array(2) { [0]=> object(RedBeanPHP\OODBBean)#37 (10) { ["properties":protected]=> array(5) { ["id"]=> int(0) ["name"]=> string(9) "Koala.jpg" ["size"]=> int(780831) ... (etc.)

But the second var_dump, after storing it gives:

array(0) { }

Why is this? Does anyone have any idea why this is happening, I've been debugging for ages and I have no idea how to fix this.


Solution

  • I fixed it, Redbean sure has some non-intuitive syntax sometimes.

    $this->pub->xownFile is the correct call, i.e. removing the plural...