And for 1.1 you need to use MySQL innoDB, set var $transactional to
true in the appropriate models. In your controller you can then do
something like (code excerpt from one of my applications):

$error_flag = false;
$this->{$this->modelClass}->execute( 'START TRANSACTION' );

// update the offline record with the paid_by method
$this->{$this->modelClass}->OfflineRecord->id = $this->{$this-
>modelClass}->OfflineRecord->field('id',
aa('OfflineRecord.payment_id', $id));

 if(!$this->{$this->modelClass}->OfflineRecord->saveField('paid_by',
Sanitize::paranoid($this->data['OfflineRecord']['paid_by'])))
{
     $this->Logr->error('#8827 - update of Offline field failed in
payment/receive for user ' . $this->Common->getUserVar('id') . ' and
payment code ' . $payment_code);
     $error_flag = true;
 }

if(!$this->{$this->modelClass}->setPaymentStatus($id, 'complete'))
{
    $this->Logr->error('#8827 - setPaymentStatus failed in payment/
receive for user ' . $this->Common->getUserVar('id') . ' and payment
code ' . $payment_code);
    $error_flag = true;
}

if(!$error_flag)
{
    $this->{$this->modelClass}->execute( 'COMMIT' );
    $this->Message->flash('Payment and associated bookings have been
successfully marked as received');
}
else
{
    $this->{$this->modelClass}->execute( 'ROLLBACK' );
    $this->Message->flash('Error #8827; Payment and associated
bookings were not marked as recieved due to a database error',
'error');
}

Does that make sense? Ianh


On Jul 8, 8:07 pm, "Christian \"Jippi\" Winther" <[EMAIL PROTECTED]>
wrote:
> Hello
>
> For CakePHP 1.2 you can use my model 
> behaviorhttp://bakery.cakephp.org/articles/view/transaction-behavior(Should 
> work
> with most databases, though it was developed for MySQL innodb)
>
> If you do not wish to use it (Might be overkill for some people),  you
> should be able to do just
>
> $this->ModelName->begin();
>
> $this->ModelName->commit();
>
> $this->ModelName->rollback();
>
> Since the overloaded php4/5 model base class is using the magic method
> __call that just pass unknown commands for the model directly to the SQL
> server as a command
>
> ---
>
> Christian "Jippi" Winther
>
> http://docs.cakephp.nu(Unofficial CakePHP API)
>
> http://logs.cakephp.nu(Unofficial CakePHP IRC log)
>
> From: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf
> Of Larry E. Masters aka PhpNut
> Sent: 8. juli 2007 18:37
> To: cake-php@googlegroups.com
> Subject: Re: Does cakephp support transaction now?
>
> On 7/8/07, sTb <[EMAIL PROTECTED]> wrote:
>
> Read the fucking manuall!
> if you want to use more models in your application 
> readhttp://manual.cakephp.org/chapter/models
>
> This will be the first and only warning, let it happen again and I will ban
> you.
> There is no reason to use this language in the group.
>
> --
> /**
> * @author Larry E. Masters
> * @var string $userName
> * @param string $realName
> * @returns string aka PhpNut
> * @access  public
> */


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to