Search code examples
redbean

many to many in redbeanphp is not full


I've created bean called user

$user =  = R::dispense('user');
$user->sharedInstrument = $instruments;

And create an instrument where the owner is a user and many users can view it

$instrument = R::dispense('instrument');
$instrument->sharedUser = $users;
$instrument->owner = $owner;

The problem is when I load an instrument $instrument->sharedUser seems to only consist of the owner. Is there a way to get around this other than using R::related($instrument,'user')?


Solution

  • Found out how to do it use preload with an alias.

    R::preload($instrument,array('sharedUser'=>'user'));