The proper way could also be :
try {
...........
$this->begin()
.......
$this->commit()
..........
} catch (Exception $e) {
$this->rollback();
throw $e;
}
everywhere there is a transaction begininig...
On 12 déc, 18:40, Sandreu <[email protected]> wrote:
> A nicely coded rollback function should do the rollback only when a
> transaction has started.
> If rollback is not implemented in the dbsource, it will just not
> rollback...
> I think that when an PDOerror occurs, it's the dbsource's role to
> rollback the transaction to avoid blocking of every following insert/
> update failing.
>
> It's not the Model role because it's a db source error...
>
> Imagine that :
>
> class Controller.. {
> function action() {
> try {
> do something......
> throw new PDOException();
> } catch (Exception $e) {
> don't care what's the error I want to save something into the
> db
> $this->model->save(....);
> }
>
> }
>
> The $this->model->save(....); won't work....
>
> I think it's the db source to rollback, because I shouldn't have to do
> the rollback in this previous case.
>
> On 12 déc, 15:29, José Lorenzo <[email protected]> wrote:
>
>
>
>
>
>
>
> > Not all databases support transactions, and not all requests begin with
> > one. So it would make sense for you to do it in your models, I don't see
> > cake handling that automatically.
--
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