mercredi 28 octobre 2015

How to make pdf using mpdf that have big data in codeigniter?

I have some problems were using mpdf with a large data.

I'm using Codeigniter as backend framework and the database is SQL Server

I have set the memory limit to -1 =====> ini_set('memory_limit', -1); It works when I have a small data, e.g. 100 rows.

But, now I have 1000 rows and I got this error

Fatal error: Out of memory (allocated 823394304) (tried to allocate 230352 bytes) in C:\xampp\htdocs\simas\application\third_party\mpdf\mpdf.php on line 14487

what's wrong with my code? or how to fix this mpdf?

queries in model :

SELECT t.tgl_buku as tglbuku, t.kd_brg as kdbarang, b.namabarang, t.no_aset as qty, t.jns_trn, t.rph_aset as jumlah,t.asal_perlh as asal, t.merk_type as merk, t.keterangan, t.no_bukti as nobukti FROM as_transaksi t join ms_barang b on t.kd_brg = b.kdbarang WHERE t.jns_trn like '1%' and year(t.tgl_buku) = '2013' and month(t.tgl_buku) <= 6

table in view :

<table width="100%">
            <thead>
                <tr style="background:#C0C0FF; text-align:center;">
                    <center>
                    <td>Tgl Buku</td>
                    <td>Kd Barang</td>
                    <td>Nama Barang</td>
                    <td>Qty</td>
                    <td>Nilai</td>
                    <td>Supplier</td>
                    <td>Merk</td>
                    <td>Keterangan</td>
                    </center>
                </tr>
            </thead>
            <?php
            if (!empty($isdata)) {
                $total=0;
                foreach ($isdata as $row) {
                    $total=$total+($row->jumlah*$row->qty);
                    echo "<tr>";
                    echo "<td>". date('d-m-Y',strtotime($row->tglbuku))."</div></td>";
                    echo "<td>".$row->kdbarang."</div></td>";
                    echo '<td>'.$row->namabarang."</td>";
                    echo "<td>".$row->qty."</div></td>";
                    echo "<td>".$row->jumlah."</div></td>";
                    echo '<td>'.$row->asal."</td>";
                    echo '<td>'.$row->merk."</td>";
                    echo '<td>'.$row->keterangan."</td>";
                    echo '</tr>';
                }
            }else{
                echo "<tr>";
                echo "<td></td>";
                echo "<td></td>";
                echo "<td></td>";
                echo "<td></td>";
                echo "<td></td>";
                echo "<td></td>";
                echo "<td></td>";
                echo "<td></td>";
                echo "</tr>";
            }
            ?>
            <tr>
                <td></td>
                <td colspan="3">Total</td>
                <td><div align="right"><b><?=convertrp($total);?></b></div></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
        </table>

Please someone help me :)




Aucun commentaire:

Enregistrer un commentaire