php - 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 也不会打印在页面中。我无法弄清楚问题所在。有什么帮助吗?非常感谢!!
解决方案
关于你得到的错误,它只是意味着字段 Deskripsi 对于 getnrc01() 中的 SQL 查询的至少一个结果有一个空值(但我猜这是预期的,因为你的查询有一个 LEFT JOIN 子句)。但这不是严重错误,在这种情况下该行<td><?php echo $record->Deskripsi ?></td>
只会显示<td></td>
。
关于另一个问题,您发布的代码中没有提到任何“contractType”。您可能忘记发布一个部分?
推荐阅读
- java - Java Spring Boot中的Mongo Repository findById不起作用
- django - Django重命名类导致AttributeError:'str'对象没有属性'_meta'
- java - 了解优先队列的工作原理
- node.js - 本地 AWS API 网关
- c# - 无法将 lambda 表达式转换为类型对象,因为它不是委托类型
- javascript - 从类的特定元素获取属性
- jenkins - 想要删除 Jenkins 作业
- typescript - IONIC上的路线
- rabbitmq - 使用spring-amqp库异步发送消息时如何使用rabbit mq处理网络超时异常
- r - R定义没有观察的水平