Uffo
Uffo

Reputation: 10056

Zend framerwork execute code on module preDispatch

Hi there so I created a Zend_Controller_Plugin_Abstract and on routeStartup I do some checkings and insert data into the database, the problem is if I access a page only once, it executes like 5 times, so I will have 5 rows in the table.

Do you know how to do a controller preDispatch function that it will only execute once, I need to do some checkings everytime to user, refreshes/access a page.

Upvotes: 0

Views: 110

Answers (1)

Tim Fountain
Tim Fountain

Reputation: 33148

The controller plugin methods should only execute once. The only reason they wouldn't is if you application uses _forward() to forward the request to another action, as this results in another dispatch cycle.

I'd suggest adding a little debugging in your function temporarily to log the REQUEST_URI perhaps using error_log(). It might be something like your browser requesting /favicon.ico, which results in a 404 page which is also served by your ZF app (thus also uses the plugin).

Upvotes: 1

Related Questions