数据库到代码点火器的pdf

时间:2016-04-27 12:08:23

标签: php codeigniter pdf

我想在代码点火器中生成一个pdf文件, 我使用CI数据库实用程序以csv格式从db获取数据

我的模特就是这个......

 function prr(){
        $id=$this->db->insert_id();
        $query = $this->db->query("SELECT * FROM bookings where did='1' && email='jk@gmail.com' && id='$id'");
        $result2=$this->dbutil->csv_from_result($query); 
        return $result2;
    }    

我得到这样的结果..但知道如何用pdf打印它?

"id","did","email","mobile","slot","disease","age","gender","date", "18","1","jk@gmail.com","8528263923","morning-to-noon"," bjlk","bk","male","28-04-2016", 

1 个答案:

答案 0 :(得分:0)

function prr(){
    $id=$this->db->insert_id();
    $query = $this->db->query("SELECT * FROM bookings where did='1' && email='jk@gmail.com' && id='$id' ");
    $result = $query->result_array();

    $pdfFilePath = FCPATH."/downloads/reports/query.pdf";

    ini_set('memory_limit','32M'); // boost the memory limit if it's low <img class="emoji" draggable="false" alt="" src="https://s.w.org/images/core/emoji/72x72/1f609.png">

    $this->load->library('pdf');
    $pdf = $this->pdf->load();
    $pdf->SetFooter($_SERVER['HTTP_HOST'].'|{PAGENO}|'.date(DATE_RFC822)); // Add a footer for good measure <img class="emoji" draggable="false" alt="" src="https://s.w.org/images/core/emoji/72x72/1f609.png">
    $pdf->WriteHTML($result); // write the HTML into the PDF
    $pdf->Output($pdfFilePath, 'F'); // save to file because we can
}

Using mpdf with codeigniter