2008年12月23日星期二

Re: [fw-db] $db->isInTransaction ?

There is no way currently to tell if you are "inside" of a transaction. I
am not sure I would use the Controller's Error Handling as your transaction
try/catch block.

I think the best practice is to start a transaction inside your action, put
all the steps between your try block, and catch any exceptions and roll back
within that action. At that point, you can then throw a
Zend_Controller_Action_Exception (or any exception) to force the controller
to go into your error controller. This would then isolate the data access
logic to your action controller that requires it.

Is there a compelling reason to use the controller error handling for your
data access transaction rollback?

-ralph


On 12/23/08 4:01 AM, "Lucas Corbeaux" <lucas.corbeaux@gmail.com> wrote:

> Hi there,
>
> I have a little question...
>
> In a MVC projet, I have an error controller wich catch unhandled
> exceptions and log them into DB. In some case, an exception is throwed
> in a transaction, and, for my DB Logger to work, I need to rollback in
> my Error controller. Is there any easy solution to know if you are in a
> DB transaction with a PDO_MYSQL adapter ?
>
> Actually, I manually use Zend_Registry to modify the 'isInTransaction'
> entry states... I think it's not a really good way.
>
> Thanks for your help,
> Lucas
>

--
Ralph Schindler
Software Engineer | ralph.schindler@zend.com
Zend Framework | http://framework.zend.com/

没有评论: