使用MVC从mssql数据库填充PDF

时间:2016-01-25 08:58:47

标签: sql-server codeigniter pdf stored-procedures model-view-controller

我想从我的数据库中获取数据以填充PDF中的某些字段,我有我的MVC的示例代码,我需要一些SP的帮助,因为我不熟悉SQL,任何类型的帮助都将是赞赏。

控制器

function downloadform()
        {   

                $data['info']= $this->uri->segment(3);
                $this->load->model('navi_model');
                $query =  $this->navi_model->gen048_welletter($data);
                $data['viewlist'] = $query;
            //  $hello = $this->load->view('view', $data);
                $this->load->library('mpdf');       



                $hello ='
                <img src="'.base_url().'images/ubplogo.png"></img>
                <br/><br/>
                <table width="100%" border="0">
                <tr>
                <td width="18%"><strong>Request No. :</strong></td> <td> <span class="space">'.$data['viewlist'][0]->accnum .'</span></td>
                <td width="15%">  <strong>Control Code:</strong></td> <td style="color: blue;">'.$data['viewlist'][0]->accname . '</td>
                </tr>
                <tr>
                    <td><strong>Date Created:</strong></td><td>'. $data['viewlist'][0]->Date_Created .'</td>
                    <td><strong>Last Edited:</strong></td><td>' . $data['viewlist'][0]->Date_Edited .'</td>
                </tr>';

模型

function gen048_welletter($data)
{

$qString = '[gen048_welcomeletter] '; //STORED PROCEDURE
    $qString .= "'" 
             . $data['info'] . "','";

        //echo $qString;

        $this->db->query('set ansi_padding on
                        set ARITHABORT on
                        set CONCAT_NULL_YIELDS_NULL on
                        set QUOTED_IDENTIFIER on
                        set ANSI_NULLS on
                        set ANSI_WARNINGS on
                        set numeric_roundabort off');

        $query = $this->db->query($qString);

    //return ($query->num_rows() > 0) ? $query->result() : NULL;
}

0 个答案:

没有答案