this "trick" it's only for my logger to work even if an exception wasn't
catched, things that could happen in my project right now, in the early
part of the programming... In fact I have no "good" reasons to use error
controller to roll back.
Thank you for your answer.
Lucas
Ralph Schindler a écrit :
> 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
>>
>>
>
>
没有评论:
发表评论