致命错误:在非对象中调用成员函数result_array()

时间:2017-05-23 02:51:04

标签: php codeigniter fatal-error

之前,我会说抱歉,因为再次提出这个问题。我在这里搜索了有关'致命错误:调用成员函数'的相关主题并尝试解决方案,但此错误仍然存​​在。所以,今天我会请求你的帮助来解决这个错误。

当我按下搜索键并且结果为

时出现此错误
  

致命错误:在

中的非对象上调用成员函数result_array()

不是真实的数据。

这是我的计划:

控制器:

public function gridSearchAll() {
    $this->load->helper('form');
    $this->load->helper('lightutility');
    $this->load->model('moMasterMng');
    $this->load->model('moMasterConf');
    $this->load->model('moMasterFilling');
    $this->load->model('moUser');
    $objMUser = new moUser();
    $objMMasterMng = new moMasterMng();
    $objMMasterFill = new moMasterFilling();
    $objMMasterConf = new moMasterConf();
    $ucValue = array();
    $data = array();
    $result = '';
    $alertMsg = '';

    // get data
    $data['StartPage'] = $this->input->post('hidStartPage');
    $data['DisplayRows'] = longRows();
    $data['Ordering'] = $this->input->post('ddlOrdering');
    $data['OrderingType'] = $this->input->post('ddlOrderingType');     $data['DateRetentionFrom'] = reverseDate(cleanText($this->input->post('txtDateRetentionFrom')));
    $data['DateRetentionTo'] = reverseDate(cleanText($this->input->post('txtDateRetentionTo')));
    $data['DateArchivedFrom'] = reverseDate(cleanText($this->input->post('txtDateArchivedFrom')));
    $data['DateArchivedTo'] = reverseDate(cleanText($this->input->post('txtDateArchivedTo')));

    $data['Category'] = $this->input->post('ddlCategory');
    $data['Keyword'] = $this->input->post('txtKeyword');

    //validation
    if(!isValidDateSystem($data['DateArchivedFrom']) AND !isValidDateSystem($data['DateArchivedTo'])){
        $alertMsg .= 'Penulisan Tanggal Arsip Tidak Valid!\n';
    }
    if(!isValidDateSystem($data['DateRetentionFrom']) AND !isValidDateSystem($data['DateRetentionTo'])){
        $alertMsg .= 'Penulisan Tanggal Retensi Tidak Valid!\n';
    }
    if(empty($data['DateArchivedFrom']) XOR empty($data['DateArchivedTo'])){
        $alertMsg .= 'Tanggal Arsip Tidak Boleh Kosong Salah Satu!\n';
    }
    if(empty($data['DateRetentionFrom']) XOR empty($data['DateRetentionTo'])){
        $alertMsg .= 'Tanggal Retensi Tidak Boleh Kosong Salah Satu!\n';
    }

    $i = 0;
    $no = $data['StartPage'] + 1;
    $result .= '<table class="listcoll-tb" cellpadding="0" cellspacing="0">
            <tr class="head">
                <td class="cell">No.</td>
                <td class="cell2">Tgl&nbsp;Arsip</td>
                <td class="cell2">Ditinjau&nbsp;Kembali</td>
                <td class="cell2">Judul/Nama</td>
                <td class="cell2">No&nbsp;Batch</td>
                <td class="cell2">Deskripsi</td>
                <td class="cell2">Pemilik/Instansi</td>
                <td class="cell2">Lokasi</td>
                <td class="cell2">Petugas&nbsp;Input</td>
                <td class="cell2">Petugas&nbsp;Verifikasi</td>
            </tr>';
    if($alertMsg != ''){
        alert($alertMsg);
    }
    else{
        $dt = $objMMasterFill->populateMasterDescriptionsFilling($data);

        foreach($dt as $value)
        {
            $rowOdd = 'odd2';
            if($i % 2 == 0){
                $rowOdd = 'odd1';
            }
            $id = $value['ID'];
            $instance = '';

            $instance = $objMMasterConf->getAncestorB($value['InstanceID'], 'instance');

            $attCount = $objMMasterMng->getMasterFillFileCount($id);
            if($attCount == 0){
                $attCount = '-';
            }
            else{
                $attCount .= ' file';
            }

            if($value['DateArchived'] != '0000-00-00'){
                $value['DateArchived'] = reverseDate($value['DateArchived']);
            }
            else{
                $value['DateArchived'] = '';
            }

            $userEntry = $objMUser->getUserName($value['UserIDEntry']);
            $userVerif = $objMUser->getUserName($value['UserIDVerification']);

            $result .= '
                <tr class="row '.$rowOdd.'" id="'.$id.'">
                    <td class="cell">
                        <div class="btn-panel2">
                            '.$no.'.
                            <div class="inner hide">
                                <a href="#" class="btn-detail">Detail</a>
                            </div>
                        </div>
                    </td>
                    <td class="cell2">
                        '.$value['DateArchived'].'
                    </td>
                    <td class="cell2">
                        '.$value['DateRetention'].'
                    </td>
                    <td class="cell2">
                        '.$value['Title'].'
                    </td>
                    <td class="cell2">
                        '.$value['Code'].'
                    </td>
                    <td class="cell2">
                        '.$value['Description'].'
                    </td>
                    <td class="cell2">
                        '.$instance.'
                    </td>
                    <td class="cell2">
                        '.$value['ClassLoc'].'
                    </td>
                    <td class="cell2">
                        '.$userEntry.'
                    </td>
                    <td class="cell2">
                        '.$userVerif.'
                    </td>
                </tr>
                ';
            $i ++;
            $no ++;
        }
    }
    if($i < 3 AND $i > 0){
        $result .= '
            <tr class="row">
                <td class="cell2" style="height:120px;"></td>
                <td class="cell2" colspan="12"></td>
            </tr>';
    }
    elseif($i == 0){
        $result .= '
            <tr class="row">
                <td class="cell2" colspan="12" style="height:160px;">
                    <div class="empty">Kosong</div>
                </td>
            </tr>';
    }
    $result .= '</table>';
    $result .= $this->load->view('userControls/lib/ucTooltip', '', true);
    return $result;
}

型号:

public function populateMasterDescriptionsFilling($data){
    $result;
    $where = array();
    $order = array();
    $limit = array();

    if(!empty($data['DateArchivedFrom']) AND !empty($data['DateArchivedTo'])){
        $where['master_filling.DateArchived >='] = $data['DateArchivedFrom'];
        $where['master_fillling.DateArchived <='] = $data['DateArchivedTo'].' 24:00:00';
    }
    if(!empty($data['DateRetentionFrom']) AND !empty($data['DateRetentionTo'])){
        $where['master_filling.DateRetention >='] = $data['DateRetentionFrom'];
        $where['master_filling.DateRetention <='] = $data['DateRetentionTo'].' 24:00:00';
    }
    if(!empty($data['Keyword'])){
            $like['master_filling.'.$data['Category']] = $data['Keyword'];
    } else{
            $like['master_location.Code'] = $data['Keyword'];
    }

    $order[$data['Ordering']] = $data['OrderingType'];
    $limit[$data['DisplayRows']] = $data['StartPage'];

    $result = StoredProcedure::MSPSelectMasterDescriptionsDynamicFill($where, $order, $limit);

    return $result;
}

库:

public static function MSPSelectMasterDescriptionsDynamicFill($where, $order, $limit){
    self::$loadDb->db->where($where);
    self::$loadDb->db->order_by(key($order), $order[key($order)]);
    self::$loadDb->db->limit(key($limit), $limit[key($limit)]);
    $dset = self::$loadDb->db->get('master_filling');
    return $dset->result_array();
}

我非常感谢你的帮助。

1 个答案:

答案 0 :(得分:0)

错误消息告诉您$dset此处

$dset = self::$loadDb->db->get('master_filling');

不是您认为的对象。尝试添加

error_log('$dset = '.print_r($dset,TRUE));
紧接在该语句之后

,然后检查错误日志。