see atomic option for saveAll()

2012/1/11 Patrick <[email protected]>:
> Hi, I'm new to cakephp and I want to know more about transactions in
> saveAll().
> This is my script:
>
> <?php
>
> ...
>
> $this->BranchRequest->query('SET AUTOCOMMIT = OFF');
> $this->BranchRequest->begin();
>
> if(!$this->Count->save($this->count_header))
> {
>        $this->BranchRequest->rollback();
>        $this->Session->setFlash('save() count_header failed');
>        $this->redirect(array('action' => 'add'));
> }
>
> $this->BranchRequest->create();
> unset($this->BranchRequest->BranchRequestDetail-
>>validate['branch_request_id']);
> if(!$this->BranchRequest->saveAll($this-
>>data,array('validate'=>'first','atomic'=>'true')))
> {
>        $this->BranchRequest->rollback();
>        $this->Session->setFlash('saveAll() header and detail failed');
>        $this->redirect(array('action' => 'add'));
> }
>
> if(!$this->Count->save($this->count_code))
> {
>        $this->BranchRequest->rollback();
>        $this->Session->setFlash('save() count_code failed');
>        $this->redirect(array('action' => 'add'));
> }
>
> $this->BranchRequest->commit();
>
> ...
>
> ?>
>
> My goal is if one of the save() or saveAll() functions it fails,
> everything from begin() will rollback().
> The problem is, it seems every time saveAll() executed, it has own
> commit() BEFORE and AFTER the query.
> So if the saveAll() function fails, it can't rollback() the first
> save() functions.
> Likewise, if the saveAll() is successful but the save($this-
>>count_code) fails, it can't rollback() too.
> My question, is it possible to turn off transactions in saveAll()
> functions?
>
> I hope somebody can help, it drive me crazy.
> Thanks in advance,
>
> Patrick
>
> --
> Our newest site for the community: CakePHP Video Tutorials 
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help 
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group at 
> http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to