2008年7月31日星期四

Re: [fw-db] _DB , Transactions usage questions

Are the queries returning SQL errors or just not performing the action
properly?

That block will only rollback if an actual exception is thrown. If the query
just isn't producing the correct result, then you should check that in the
try block and throw your own exceptions.

Kevin


On 7/31/08 2:23 PM, "maxarbos" <maxarbos@yahoo.com> wrote:

>
> Hello,
>
> i have a question about Zend_DB
>
> 1: I am using transactions and it seems that my try block is not working
> correctly.
>
> Here is the code:
>
> $this->_db->beginTransaction();
>
> try {
> $this->block->doSomethingOne($one_info_action, $vals);
> $this->block->doSomethingTwo($two_info_action, $vals);
>
> $this->_db->commit();
>
> } catch (Exception $e) {
> $this->_db->rollBack();
> echo $e->getMessage();
> }
>
>
> Is this valid? Will the transaction and try block work correctly (if
> doSomethingOne and doSomethingTwo both succeed, then and only then, do the
> results commit)? I have a block just like this, but it seems as though some
> of the methods succeed, while others dont. Can methods be checked within a
> try/transaction block? (i hope this makes sense)
>
> Thanks.

没有评论: