gpt4 book ai didi

php - 严重性 : Notice Message: Trying to get property of non-object codeigniter

转载 作者:行者123 更新时间:2023-11-30 21:37:07 25 4
gpt4 key购买 nike

<分区>

我的 Controller :

function generateallmonthreport()
{
$month = $this->input->post('month');
$year = $this->input->post('year');
$familyid = $this->session->userdata('family_id');

$fulldata['dates'] = $this->Itemreport_model->getreportallmonth($month,$year);
$fulldata['members1'] = $this->Itemreport_model->getindependentmembers($familyid);
$fulldata['members2'] = $this->Itemreport_model->getindependentmembers($familyid);
$fulldata['members3'] = $this->Itemreport_model->getindependentmembers($familyid);
$fulldata['members4'] = $this->Itemreport_model->getindependentmembers($familyid);
$fulldata['members5'] = $this->Itemreport_model->getindependentmembers($familyid);
$fulldata['year'] = $year;
$fulldata['month'] = $month;

$this->load->view('header');
$this->load->view('itemreports/allmonthreportpage', $fulldata);
$this->load->view('footer');
}

我的模型:

function getreportallmonth($month,$year)
{
$sql = "SELECT DISTINCT `item_date` FROM `items` WHERE MONTH(`item_date`)='$month' AND YEAR(`item_date`)='$year'";
$query = $this->db->query($sql);
return $query->result();
}

function getindependentmembers($familyid)
{
$sql = "SELECT * FROM `familymember` WHERE `family_id`='$familyid' AND `dependency`='1'";
$query = $this->db->query($sql);
return $query->result();
}

function getcountofexpensetype($memberid,$year,$month)
{
$sql = "SELECT COUNT(DISTINCT `item_expensetype`) AS spancount FROM `items` WHERE `item_purchaseby`='$memberid' AND MONTH(`item_date`)='$month' AND YEAR(`item_date`)='$year' AND `item_expensetype` IS NOT NULL";
$query = $this->db->query($sql);
return $query->result();
}

function getexpensetype($memberidforexpensetype,$year,$month)
{
$sql = "SELECT DISTINCT `item_expensetype` as expensetype FROM `items` WHERE `item_purchaseby`='$memberidforexpensetype' AND MONTH(`item_date`)='$month' AND YEAR(`item_date`)='$year' AND `item_expensetype` IS NOT NULL";
$query = $this->db->query($sql);
return $query->result();
}

function getallitems($thisdate)
{
$sql = "SELECT `item_name`,`item_price`,`item_purchasetype` FROM `items` WHERE `item_date`='$thisdate'";
$query = $this->db->query($sql);
return $query->result();
}

function getexpensetypefinal($memberidforexpensetypeprice,$year,$month)
{
$sql = "SELECT DISTINCT `item_expensetype` as expensetype FROM `items` WHERE `item_purchaseby`='$memberidforexpensetypeprice' AND MONTH(`item_date`)='$month' AND YEAR(`item_date`)='$year' AND `item_expensetype` IS NOT NULL";
$query = $this->db->query($sql);
return $query->result();
}

我的看法:

<table border="2" id="tab" style="width:100%" class="text-center m-auto table table-bordered table-hover">

<tr>
<td rowspan="2">Date</td>
<td rowspan="2">Items</td>

<!-- php code for getting all individual member header for individual expense types -->

<?php foreach ($members1 as $members1) { ?>
<?php
$this->load->model('Itemreport_model');
$memberid = $members1->member_id;
$countforcolspan = $this->Itemreport_model->getcountofexpensetype($memberid,$year,$month);
?>

<td colspan="<?php foreach ($countforcolspan as $countforcolspan) { echo $countforcolspan->spancount+1; } ?>">
<?php echo $members1->membername."'s Individual Expenses"; ?>
</td>

<?php } ?>

<td rowspan="2">Total Expense On Common</td>

<!-- php code for getting all individual member header -->
<?php foreach ($members2 as $members2) { ?>
<td rowspan="2"><?php echo $members2->membername."'s Total Expense (Individual + Common)"; ?></td>
<?php } ?>

<td rowspan="2">Total Expense Of Family</td>
</tr>

<tr>
<?php
foreach ($members3 as $members3) {
$memberidforexpensetype = $members3->member_id;
$expensetype = $this->Itemreport_model->getexpensetype($memberidforexpensetype,$year,$month);
foreach ($expensetype as $expensetype) { ?>
<td><?php echo $expensetype->expensetype; ?></td>
<?php } ?>
<td>Total</td>
<?php }
?>
</tr>

<tbody id="tbodydata">

<?php foreach ($dates as $dates) { ?>
<tr>

<td><?php $thisdate = $dates->item_date; echo $thisdate; ?></td>

<td><?php
$allitems = $this->Itemreport_model->getallitems($thisdate);
foreach ($allitems as $allitems) {
echo $allitems->item_name; ?> (<?php echo $allitems->item_price; ?>)
<?php }
?></td>

<?php foreach ($members4 as $members4) {
$memberidforexpensetypeprice = $members4->member_id;
$countforcolspan = $this->Itemreport_model->getexpensetypefinal($memberidforexpensetypeprice,$year,$month);
} ?>
</tr>
<?php } ?>

</tbody>

代码似乎工作正常但给了我尝试获取非对象属性的通知

错误:

A PHP Error was encountered Severity: Notice Message: Trying to get property of non-object Filename: itemreports/allmonthreportpage.php Line Number: 68

Backtrace: File: D:\wampserver\www\home\application\views\itemreports\allmonthreportpage.php Line: 68 Function: _error_handler

File: D:\wampserver\www\home\application\controllers\Itemreport.php Line: 91 Function: view

File: D:\wampserver\www\home\index.php Line: 315 Function: require_once

我无法发现代码的不当部分..请帮助..!!

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com