title: CakePHP - insert into multiple tables error
body: <p>I'm trying to save data to more tables using CakePHP (2.4.6).</p>
  
  <p>I have Posts/add.tcp file:</p>
  
  <pre><code>&lt;?php
  echo $this-&gt;Form-&gt;create('Post');
  echo $this-&gt;Form-&gt;input('title');
  echo $this-&gt;Form-&gt;input('body', array('rows' =&gt; '3'));
  echo $this-&gt;Form-&gt;end('Save Post');
  ?&gt;
  </code></pre>
  
  <p>And method add in PostsController file:</p>
  
  <pre><code>public function add() {
      if ($this-&gt;request-&gt;is('post')) {
          $this-&gt;request-&gt;data['Post']['user_id'] = $this-&gt;Auth-&gt;user('id');
  
  $titulek = $this-&gt;request-&gt;data['Post']['title'];
  $uid=$this-&gt;request-&gt;data['Post']['user_id'];
  $body=$this-&gt;request-&gt;data['Post']['body'];
  
  $sqla = "INSERT INTO posts (title,created,user_id) VALUES ('$titulek', NOW(),'$uid')";
  $sqlb = "INSERT INTO forums (user_id,post_id,text,created) VALUES ('$uid',NULL,'$body', NOW())";
  
  if ($this-&gt;Post-&gt;query($sqla)) {
  if ($this-&gt;Post-&gt;query($sqlb)) {
              $this-&gt;Session-&gt;setFlash(__('Your post has been saved.'));
              return $this-&gt;redirect(array('action' =&gt; 'index'));
  }
          }
      }
  }
  </code></pre>
  
  <p>But it doesn't work as intended. Only <code>$sqla</code> query is actually saved to the database. <code>$sqlb</code> query isn't executed at all and at the end I'm not redirected to another page. It's interesting that if I reverse the order of queries (e.g. current <code>$sqlb</code> query becomes <code>$sqla</code> query and <code>$sqlb</code> query becomes <code>$sqla</code> query the <code>INSERT INTO forums</code> query executes correctly but <code>INSERT INTO posts</code> isn't, so it seems that both queries are written correctly and for some reason only first of them executes). What am I doing wrong? I just want to insert custom query into more tables in one action. Thanks in advance for any help.</p>