title: Saving data with saveAll() in CakePHP
body: <p>This might not be the problem with saveAll, the situation is like this. I have table messages, and table sent_messages, which holds message id and user id. Models are created, where Messaage hasMany SentMessage, and SentMessage belongsTo Message. I need to save just one message in <em>messages</em> table, and save user ids and message id in *sent_messages* table. The problem starts when I try to save that in MessageController. Here is the code:</p>
  
  <pre><code>function custom() {
      if (!empty($this-&gt;data)) {
          $this-&gt;loadModel('User');
          $userIDs = $this-&gt;User-&gt;listActiveUsers();
          $this-&gt;data['Message']['message_type_id'] = 2;
          if ($this-&gt;Message-&gt;save($this-&gt;data)) {
              array_pop($this-&gt;data);
              foreach ($userIDs as $key =&gt; $value ) {
                  $this-&gt;data['SentMessage'][$key]['user_id'] = $value;
                  $this-&gt;data['SentMessage'][$key]['message_id'] = $this-&gt;Message-&gt;getLastInsertID();
              }
              //die($this-&gt;Message-&gt;SentMessage-&gt;saveAll($this-&gt;data));
  
              if ($this-&gt;Message-&gt;SentMessage-&gt;saveAll($this-&gt;data)) {
                  $this-&gt;Session-&gt;setFlash('Data saved', 'success');   
              }
              else {
                  $this-&gt;Session-&gt;setFlash('Data not saved', 'error');
              }    
          }
      }  
  }
  </code></pre>
  
  <p>Any help would be appreciated.</p>