我在控制器文件中有以下代码,用于检查post varible pdf并执行以下代码
if(isset($_POST['pdf']) && $_POST['pdf']=="pdf")
{
$this->load->model('voutput_model');
$final_view = $data['frmReport'];
$PDF_Name = "report.pdf";
$this->votput_model->pdf($PDF_Name,$final_view);
}
我在模型文件中有以下代码
class Voutput_model extends CI_Model{
public function __construct()
{
parent::__construct();
$this->CI = get_instance();
}
public function pdf($file_name,$filecontents){
$this->pdf_path = $this->config->item('pdf_path');
$this->load->library('htmltopdf/Html2fpdf');
$file['Attach_path'] = $this->pdf_path.$file_name;
$this->html2fpdf->generate_pdf($file['Attach_path'],$filecontents,'Y');
}
}
当我执行代码时,我收到如下错误:
Severity: Notice
Message: Undefined property: Voutput::$Voutput_model
Filename: controllers/voutput.php
Fatal error: Call to a member function pdf() on a non-object in
C:\xampp\htdocs\asset\application\controllers\voutput.php
答案 0 :(得分:4)
您需要在使用前加载模型。试试这个
$this->load->model('votput_model');
$this->votput_model->pdf($PDF_Name,$final_view);