致命错误:在MVC / MsSql中的非对象上调用成员函数result()

时间:2016-02-03 01:17:20

标签: php sql-server json codeigniter

我使用codeigniter作为我的框架和MsSql用于我的数据库,我对我的json脚本有一些疑问,因为它是我第一次使用它。每当我加载页面时,表格只显示"处理......"当我从我的数据库中搜索时,会出现图像中的错误。

我不知道我的存储过程是否没有执行。

enter image description here

  

dbo.SEARCH_gen048,' ASC',1,10,1,&#39 3/11/2016年'致命错误:在/home/development/public_html/rmt/application/models/navi_model.php中调用非对象的成员函数result()

我没有对涉及此模块的代码做任何事情,我可以在这里寻求帮助吗?

控制器

function search_gen048() {

$data['fDate']=$this->input->post('dateData');
$this->load->model('navi_model');
$this->navi_model->get_gen048($_GET);

}

    function get_gen048(){
    $this->load->model('navi_model');
    $this->navi_model->srch_gen048($_GET);


}

模型

function srch_gen048($data){


    $sEcho = intval($data["sEcho"]);
    $iDisplayStart = intval($data["iDisplayStart"]); //start of record
    $iDisplayLength = intval($data["iDisplayLength"]); //display size
    $pageNum = ($iDisplayStart/$iDisplayLength)+1; //page num
    $colSort = $data['iSortCol_0'];
    $dirSort = strtoupper($data['sSortDir_0']);

    $qString = "SEARCH_gen048";
    $qString .= "" . $colSort . ",";
    $qString .= "'" . $dirSort . "',";
    $qString .= "" . $pageNum . ",";
    $qString .= "" . $iDisplayLength . ",";
    $qString .= "" . $sEcho . ",";
    $qString .= "'" . $data['fromDate'] . "'";

    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');

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

    $iTotalDisplayRecords   = 0;
    $iTotalRecords          = 0;
    if(count($res) > 0)
    {
        $iTotalDisplayRecords = intval($res[0]->TOTAL_ROWS); //used for paging/numbering; same with iTotalRecords except if there will be search filtering
        $iTotalRecords = intval($res[0]->TOTAL_ROWS); //total records unfiltered
    }

    $output = array(
        "sEcho" => intval($sEcho),
        "iTotalRecords" => $iTotalRecords,
        "iTotalDisplayRecords" => $iTotalDisplayRecords,
        "aaData" => array()

    );

    if(count($res) > 0)
    {
        foreach($res as $row)
        {
                                $output['aaData'][] = array(
                                        $row->accnum,
                                        $row->accname,
                                        $row->add1,
                                        $row->accdate,
                                        $row->uname,
                                        $row->add4,
                                        $row->bzip,
                                        ''
                                        );
        }
    }
    return json_encode( $output );
}

查看

<script>
$(document).ready( function () {
    $('#acctable').dataTable({
    "sPaginationType": "full_numbers",
    "bAutoWidth": false,
    "bFilter": false,
    "bProcessing": true,
    "bLengthChange": false,
    "bServerSide": true,
    "sAjaxSource": "<?php echo site_url() ?>/welcome/get_gen048",
    "sServerMethod": "GET",
    "fnServerData": function ( sSource, aoData, fnCallback ) {
        aoData.push( { "name": "fromDate"   , "value": "<?php echo $_POST["fromDate"] ?>" } );
        $.getJSON( sSource, aoData, function (json) {
        fnCallback(json);

        } );
        },
        "aoColumns": [
        { "sClass": "leftAligned"   , "bSortable" : true, "bAutoWidth": false },
        { "sClass": "rightAligned"  , "bSortable" : true, "bAutoWidth": false },
        { "sClass": "rightAligned"  , "bSortable" : true, "bAutoWidth": false },
        { "sClass": "rightAligned"  , "bSortable" : true, "bAutoWidth": false },
        { "sClass": "rightAligned"  , "bSortable" : true, "bAutoWidth": false },
        { "sClass": "rightAligned"  , "bSortable" : true, "bAutoWidth": false },
        { "sClass": "rightAligned"  , "bSortable" : true, "bAutoWidth": false }

        ]   

                            }); 
} );

</script>
From: <input  type="text" name="fromDate" id="fromDate" readonly /></p>
<input type="submit" value="Submit" name="dateData" id="dateData"/>

0 个答案:

没有答案