title: Save inside loop
body: <p>I created a function that has a infinite loop and a delay at the end to make sure it will only execute one time per second.</p>
  
  <p>This function is in a shell class and its goal is to save/update records in three different tables and I invoque it from the console line using the command 'cake className'</p>
  
  <p>My problem is:</p>
  
  <p>I stop the loop at the console (Ctrl + C) and only the last record is saved in the database.</p>
  
  <p>I don't know if there is some problems with transaction, i tried to use begin() before save and commit after, but the problem subsisted. </p>
  
  <p>The code is something like this:</p>
  
  <pre><code>$this-&gt;T1-&gt;begin();
  $this-&gt;T2-&gt;begin();
  $this-&gt;T3-&gt;begin();
  
   if ($this-&gt;T1-&gt;save((array (
      'Field1' =&gt; $val1,
      'Field2' =&gt; $val2,
      'Field3' =&gt; $val3))) 
      &amp;&amp; $this-&gt;T2-&gt;save(array (
        'Field1' =&gt; $val4,
        'Field2' =&gt; $val5,
        'Field3' =&gt; $val6))) 
      &amp;&amp; $this-&gt;T3-&gt;saveField('Field1', $val7)) 
   {
        $this-&gt;T1-&gt;commit();
        $this-&gt;T2-&gt;commit();
        $this-&gt;T3-&gt;commit();
  
        echo 'success message';
   }
  </code></pre>