transactions...
"For transactions to work correctly in MySQL your tables must use
InnoDB engine. Remember that MyISAM tables do not support
transactions." - from SaveAll page of manual http://bit.ly/nUJyv2
On Sep 30, 11:42 pm, "succer...@tiscali.it" <succer...@tiscali.it>
wrote:
> Hi everybody! :)
>
> I'm trying to understand how to use transactions in cakephp:
> i have this 2 different table, let's say
> A: name, surname, id, code_b, data, point
> B: name, surname, id, code, score
>
> and when i make an insert into A i have to update the score of B,
> adding the point of A.
>
> i wrote something like:
>
> function add()
> {
> if(isset($this->data))
> {
> Controller::loadModel('Father');
> $authstring=$this->Session->read('Auth.User');
> $Father=$authstring['CodeB'];
>
> $this->data['A']['Father']=$Father;
>
> $dataSource->begin($this);
>
> if ($Father=$this->Father->find('first', array('conditions' =>
> array('CodiceFather' => $this->data['FatherA']))))
> {
> $oldScore=$Father['PreferenzePrevisteReferenze'];
> $newScore=($tihs->Data['PersoneCollegate']*$this->Data['ProbabilitaDiVoto'])/100;
>
> $totScorei=$oldScore+$nuoviScore;
> if($this->A->save($this->data))
> {
> if($this->Father->set('Score', $totScore))
> {
> $dataSource->commit($this);
> $this->Session->setFlash("new A was saved");
> }
> else {
> $this->Session->setFlash('Errore UPDATE');
> $dataSource->rollback($this);
> }
> }
> else {
> $this->Session->setFlash('Errore insert');
> $dataSource->rollback($this);
> }
> }
> else {
> $this->Session->setFlash('errore FIND');
> $dataSource->rollback($this);
> }
> }
>
> }
>
> is this the right way to do it? I get an error if in the A model i put
> $dataSource = $this->getDataSource();
>
> (Parse error: syntax error, unexpected T_VARIABLE )
>
> THANK YOUU!
--
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
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment