首页 > 解决方案 > codeigniter 消息:消息:未定义的属性:stdClass::$Deskripsi

问题描述

我收到了这个错误:

遇到 PHP 错误 严重性:通知

消息:未定义的属性:stdClass::$Deskripsi

文件名:views/nrc01.php

行号:70

这是我的控制器:

function nrc01()
    {
            $data['nrc01Records'] = $this->user_model->getnrc01();

            $process = 'Neraca';
            $processFunction = 'Manager/cr001a';
            $this->logrecord($process,$processFunction);

            $this->global['pageTitle'] = 'Neraca';

            $this->loadViews("nrc01", $this->global, $data, NULL);
    }

这是我的模型:

function getnrc01()
    {
        $this->dbsqlsrv = $this->load->database('dbsqlsrv', TRUE);
        $this->dbsqlsrv->select('a.posLaporanPosisiKeuangan',
                                'b.Deskripsi',
                                'a.nominalRupiah',
                                'a.nominalValas',
                                'a.nominalValasUSD',
                                'a.nominalValasNonUSD',
                                'a.nominalTotal'
                            );
        $this->dbsqlsrv->from('nrc01.neraca as a');
        $this->dbsqlsrv->join('dbo.RefAsetNeracaKantorAll as b','a.posLaporanPosisiKeuangan = b.sandi','left');
        $where = "idPelapor='137001000' AND periodeLaporan='M' AND periodeData='2019-09-30'";
        $this->dbsqlsrv->where($where);
        $this->dbsqlsrv->order_by('b.id DESC');
        $query = $this->dbsqlsrv->get();
        $result = $query->result();
        return $result;
    }

这是我的观点:

<tbody>
                    <?php
                      if(!empty($nrc01Records))
                      {
                          foreach($nrc01Records as $record)
                          {
                    ?>
                                <tr>
                                    <td><?php echo $record->posLaporanPosisiKeuangan ?></td>
                                    <td><?php echo $record->Deskripsi ?></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td class="text-center">
                                        <a class="btn btn-sm btn-info" href="<?php echo base_url(); ?>" title="Edit">
                                            <i class="fa fa-pencil"></i>
                                        </a>
                                        <a class="btn btn-sm btn-danger deleteUser" href="#" data-userid="" title="Hapus">
                                            <i class="fa fa-trash"></i>
                                        </a>
                                    </td>
                                </tr>
                                <?php
                          }
                      }
                      ?>
                  </tbody>

但是,即使它已经有值,contractType 也不会打印在页面中。我无法弄清楚问题所在。有什么帮助吗?非常感谢!!

标签: phpcodeigniter

解决方案


关于你得到的错误,它只是意味着字段 Deskripsi 对于 getnrc01() 中的 SQL 查询的至少一个结果有一个空值(但我猜这是预期的,因为你的查询有一个 LEFT JOIN 子句)。但这不是严重错误,在这种情况下该行<td><?php echo $record->Deskripsi ?></td>只会显示<td></td>

关于另一个问题,您发布的代码中没有提到任何“contractType”。您可能忘记发布一个部分?


推荐阅读