title: Redbean: How does one get last inserted id of owned Bean?
body: <p>I use RedBeanPHP 3.5.1 for ORM in my MVP project (powered by Nette FW).</p>
  
  <p>I need to get ID of the last inserted element, that is owned by element from another table. Below you can find method representing functionality which I just described:</p>
  
  <pre><code>public function createSite($userId, $siteName, $feedUrl, $reloadTime, $reloadRate){
      $site = R::dispense('site');
      $site-&gt;user_id = $userId;
      $site-&gt;name = $siteName;
      $site-&gt;feed = $feedUrl;
      $site-&gt;reload_time = $reloadTime;
      $site-&gt;reload_rate = $reloadRate;
  
      $user = R::load('user', $userId);
      $user-&gt;ownSite[] = $site;
      $id = R::store($user);
  
      return $id; 
  }
  </code></pre>
  
  <p>Now I would assume that line</p>
  
  <pre><code>$id = R::store($user);
  </code></pre>
  
  <p>would store <strong>site ID</strong> into <code>$id</code> variable since it is owned by already existing user. Instead of that it fills variable with user ID that I have no further use for.</p>
  
  <p>So my question is: <strong>How do I get last inserted ID of owned bean that was just created by calling <code>R::store()</code> method on parent (just loaded) bean?</strong> Is there an implementation on this in RedBean or do I have to do this manually?</p>
  
  <p>I browsed every corner of RedBeanPHP project web but so far no luck.</p>
  
  <p>Thanks for possible suggestions, guys.</p>