Handle Of Long Running Process In Yii

Dear All,

I have developed application for managing warehouse. It is simple in and out warehouse transaction. However, the item is about 900. The problem is when I generate monthly report, it will produce minimum 1800 rows (Initial balance and final stock). I always got reach maximum execution time. I have no idea how could I display the result on screen without reach maximum execution time.

One way that I can think of is to generate oflline into pdf/excel so that the user can see the report from a link. However, this approach has some limitation on how could I trigger the generation from web application.

Is there any yii way to do this?

Thank you in advance.


This is a PHP or Apache configuration issue. Try this function first.

I would use ajax.

Query how many results there will be then use ajax to request x amount of rows at a time.


Thank you for the great idea. However, how can I make x requests of ajax calls? I calculate that my algorithm is ok for around 50 items.



When the page is first requested get a count of all the rows that will be returned.

Then have an ajax request call a controller action and return 50 results.

Once this has been returned and rendered into the report request the next 50 then repeat until you have all records.


I create a CActiveForm and submit the ajax call via ajax button.


<div class="actions">

    <?php echo CHtml::ajaxButton('Generate', $this->createUrl('/invoice/periodeInvoicing'), array(

        'type' => 'POST',

        'beforeSend' => 'function(data,status){ $("#invoice_btn").attr("disabled", "disabled"); $("#invoice_btn").removeClass("primary"); }',

        'success' => 'invoiceSaved'), array('id' => 'invoice_btn', 'class' => 'btn primary')); ?>



How could I iteratively submit the form (simulating ajaxButton click) ?

<script type="text/javascript">

    function invoiceSaved(data, textStatus, XMLHttpRequest) {


        var obj = jQuery.parseJSON(data); 

        jQuery('#alert').bootAlert('alert', obj.status, obj.msg);

        if(obj.totInvoices <= 0) {


        } else {



 ====> need code here to resubmit the form <=====