Db Update After Page Finished Rendering


In my project I need to make custom DB updates with user statistics. I can’t force Yii (1.1.14) to make those database operations after all rendering is done.

Could you put some light on how to do it?

(My project runs on a embedded system, typical industrial PLC, on ARM with limited amount of RAM. Sqlite DB, which we run, is often locked due to PLC main C module. I can’t even use caching on that, so every page refresh is kind of heavy task for my box. Sometimes DB is locked for 1.5 second, so rendering the page, when it performs DB update before rendering becomes terrible. From users perspective it would be ok to save user activity statistics after page rendering.)

I would create something like a <img src="/pathtophpscript"> that saves the statistics and servers afterwards a transparent 1px png image. The user would see the page but it might wait 1.5 seconds to load a non important pixel on the page. I am not sure if there is a better solution, the others might have a better idea.

Make sure that the pixel is not cached, you can also give it parameters that need to be saved depending on the page details.

Maybe I need to be more specific. By "after paged finished rendering" i meant after Yii controller finished preparing and serving data to the view.