Re: Problem with transaction in version 2.0

2011-12-21 Thread socrates

Thanks all for the help, I solved in this way:
1) I move the code form the controller to the model. (I don't really
know if this help!)
2) I used the Datasource to start the transaction. (Like explained in
the docs)
3) I commit or rollback with the datasource, but the SQLLog in the
page shows only the query, and no trace of the transaction SQL code.

Code:

inside the Model
?php
  [...]

  $ds = this-getDataSource();
  $ds-begin($this);
  $result = $this-saveAssociated('params');
  if ($result) {
$ds-commit($this); // in the doc there are no trace of this, that
i have to pass like parameter the refernce to $this.
  } else {
$ds-rollback($this);
  }
?

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Problem with transaction in version 2.0

2011-12-21 Thread Matteo Landi
On Wed, Dec 21, 2011 at 9:52 AM, socrates socrates.alessan...@gmail.com wrote:

 Thanks all for the help, I solved in this way:

Are you telling us that now transactions are working properly?

 1) I move the code form the controller to the model. (I don't really
 know if this help!)
 2) I used the Datasource to start the transaction. (Like explained in
 the docs)
 3) I commit or rollback with the datasource, but the SQLLog in the
 page shows only the query, and no trace of the transaction SQL code.

That's strange even if I think it is possible cakephp will not log
everything; however, maybe some cakephp-sql expert guys would shed
some light on the subject.


Matteo


 Code:

 inside the Model
 ?php
  [...]

  $ds = this-getDataSource();
  $ds-begin($this);
  $result = $this-saveAssociated('params');
  if ($result) {
    $ds-commit($this); // in the doc there are no trace of this, that
 i have to pass like parameter the refernce to $this.
  } else {
    $ds-rollback($this);
  }
 ?

 --
 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+unsubscr...@googlegroups.com For more options, visit this group at 
 http://groups.google.com/group/cake-php




-- 
http://www.matteolandi.net/

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Problem with transaction in version 2.0

2011-12-21 Thread socrates


On 21 Dic, 14:23, Matteo Landi mat...@matteolandi.net wrote:
 On Wed, Dec 21, 2011 at 9:52 AM, socrates socrates.alessan...@gmail.com 
 wrote:

 Are you telling us that now transactions are working properly?

 That's strange even if I think it is possible cakephp will not log
 everything; however, maybe some cakephp-sql expert guys would shed
 some light on the subject.

 Matteo

Yes, i do. If I call the datasource rollback method, the query has no
effect. The same doubt I have about the SQLLog on the page.
It will be great if some cake-php developer would enlight us!

Thanks again and have a nice day.

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Problem with transaction in version 2.0

2011-12-21 Thread José Lorenzo
Only the model queries and those you manually do with query() will be 
logged. There is actually no reason for that, except that it make logs a 
lot more cleaner. If you think transaction queries should be logged, please 
open a ticket explaining your use case.

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Problem with transaction in version 2.0

2011-12-21 Thread Alessandro Manias
No it's ok, now that i know that! Surely it's a lot clearer the log in this
way. Thank you

2011/12/22 José Lorenzo jose@gmail.com

 Only the model queries and those you manually do with query() will be
 logged. There is actually no reason for that, except that it make logs a
 lot more cleaner. If you think transaction queries should be logged, please
 open a ticket explaining your use case.

 --
 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+unsubscr...@googlegroups.com 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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Problem with transaction in version 2.0

2011-12-20 Thread socrates
I found a possible solution here! Transaction Commit and 
Rollbackhttp://ask.cakephp.org/questions/view/rollback_and_commit
Tnx.

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Problem with transaction in version 2.0

2011-12-20 Thread Matteo Landi


On 12/20, socrates wrote:
 I found a possible solution here! Transaction Commit and 
 Rollbackhttp://ask.cakephp.org/questions/view/rollback_and_commit
 Tnx.

Let us know if that solves your problems.


Regards,
Matteo

 
 -- 
 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+unsubscr...@googlegroups.com For more options, visit this group at 
 http://groups.google.com/group/cake-php

-- 
http://www.matteolandi.net

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Problem with transaction in version 2.0

2011-12-20 Thread socrates
Yes, it seems to work correctly, but there some thing unclear!
if I call Model-rollback(); the changes on the associated table were made! 
If something went wrong during the insert of the new row the associated 
model table were not modified, and it's correct.
But Why if I call rollaback the changes were made ?
Maybe i'am not clear ...

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Problem with transaction in version 2.0

2011-12-20 Thread socrates
No in fact it does not solve my problem, but maybe i don't understand very 
well.
This is my piece of code:

$this-StadiobingoBet-query('SET AUTOCOMMIT = OFF');
debug($this-StadiobingoBet-begin());
if (!$this-StadiobingoBet-saveAll(null, array('atomic' = true, 
'validate' = false))) {
  $this-StadiobingoBet-commit();
} else {
  $this-StadiobingoBet-rollback();
}

If the query of save associated goes well, it have to rollback, but it does 
not.

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Problem with transaction in version 2.0

2011-12-20 Thread Matteo Landi


On 12/20, socrates wrote:
 No in fact it does not solve my problem, but maybe i don't understand very 
 well.
 This is my piece of code:
 
 $this-StadiobingoBet-query('SET AUTOCOMMIT = OFF');
 debug($this-StadiobingoBet-begin());
 if (!$this-StadiobingoBet-saveAll(null, array('atomic' = true, 
 'validate' = false))) {
   $this-StadiobingoBet-commit();
 } else {
   $this-StadiobingoBet-rollback();
 }
 

I seem to remember that model's commit and rollback functions are deprecated,
but I could be wrong; anyway, the book [1] suggests to invoke those methods on
the dataSource object (I'm not at home, so I can't confirm this is causing the
problem): give it a try.

If that does not work, try transactions inside MySQL shell, and if that works,
then analyze all the queries executed by cakephp.


Matteo

[1] 
http://book.cakephp.org/2.0/en/models/transactions.html?highlight=transactions

 If the query of save associated goes well, it have to rollback, but it does 
 not.
 
 -- 
 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+unsubscr...@googlegroups.com For more options, visit this group at 
 http://groups.google.com/group/cake-php

-- 
http://www.matteolandi.net

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Problem with transaction in version 2.0

2011-12-20 Thread Vekija
It seems that you're calling transactions methods from the model while
you should call them from the datasource instance. Try something like
this.

$datasource = $this-StadiobingoBet-getDataSource();

$datasource-begin($this-StadiobingoBet);

if($this-StadiobingoBet-saveAll($yourdata, array('validate' =
false)) {
$datasource-commit($this-StadiobingoBet);
} else {
$datasource-rollback($this-StadiobingoBet);
}


On Dec 20, 1:48 pm, socrates socrates.alessan...@gmail.com wrote:
 No in fact it does not solve my problem, but maybe i don't understand very
 well.
 This is my piece of code:

 $this-StadiobingoBet-query('SET AUTOCOMMIT = OFF');
 debug($this-StadiobingoBet-begin());
 if (!$this-StadiobingoBet-saveAll(null, array('atomic' = true,
 'validate' = false))) {
   $this-StadiobingoBet-commit();} else {

   $this-StadiobingoBet-rollback();

 }

 If the query of save associated goes well, it have to rollback, but it does
 not.

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php