Hello,
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.
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'
My problem is:
I stop the loop at the console (Ctrl + C) and only the last record is saved in the database.
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.
The code is something like this:
$this->T1->begin();
$this->T2->begin();
$this->T3->begin();
if ($this->T1->save((array (
'Field1' => $val1,
'Field2' => $val2,
'Field3' => $val3)))
&& $this->T2->save(array (
'Field1' => $val4,
'Field2' => $val5,
'Field3' => $val6)))
&& $this->T3->saveField('Field1', $val7))
{
$this->T1->commit();
$this->T2->commit();
$this->T3->commit();
echo 'success message';
}