gpt4 book ai didi

php - 收到错误未定义的属性:stdClass::$workingtime

转载 作者:行者123 更新时间:2023-11-29 17:51:54 24 4
gpt4 key购买 nike

我正在尝试从数据库获取输出,但收到错误,例如遇到 PHP 错误严重性:通知

消息:未定义的属性:stdClass::$workingtime 下面是我的代码。带有 Controller 、模型和 View 。在 $workingtime 附近的 View 上出现错误

Controller :

public function employee($id)
{

$user_record = $this->db->query("select * from usr_data where usr_id=$id")->result();
$data['title'] = 'User Dashboard';
$data['user_record'] = null;
$data['active_courses'] = [];
$data['active_coursess'] = [];
$data['course_status'] = [];
if(count($user_record)) {
$user_record = $user_record[0];
$data['title'] = ucwords($user_record->firstname.' '.$user_record->lastname).' Dashboard';
$data['user_record'] = $user_record;

$active_courses = $this->base_model->getCourseData($id);
$active_coursess =$this->base_model->gettestDetails($id);
$data['active_courses'] = $active_courses;
if(count($active_courses)) {
$data['course_status'] = $this->base_model->getCourseStatus($active_courses[0]->obj_id, $id);

$data['time_details'] = $this->base_model->getActiveCourseTimeSpent($active_courses[0]->obj_id, $id);
}
}
$this->load->view('employe-dashboard', $data);
}

型号:

public function gettestDetails($user_id)
{
return $this->executeSelectQuery("SELECT o.title ,ta.*,tpr.workingtime,tcr.mark_official,(tcr.reached_points/tcr.max_points)*100 as result FROM object_data o,usr_data u,tst_active ta, tst_tests tt,tst_pass_result tpr, tst_result_cache tcr WHERE u.usr_id=ta.user_fi and tt.obj_fi=o.obj_id and ta.test_fi=tt.test_id AND ta.active_id=tpr.active_fi AND tcr.active_fi=ta.active_id AND u.usr_id=$user_id and o.type='tst'");
}

查看:

<table class="table" id="myTable">
<thead>
<tr>

<th>Course Name</th>
<th>Duration</th>
<th>Attempts</th>
<th>Status</th>
<th>Result</th>
</tr>
</thead>

<tbody>

<?php
foreach($active_courses as $test) {
$inner_details = $this->base_model->gettestDetails($user_record->usr_id);
//echo "<pre>"; print_r($inner_details); die();
// $time_spent = 0;
// if($inner_details)
// $time_spent = $inner_details->workingtime;

?>
<tr>
<td><?php echo ucfirst($test->title); ?></td>
<td>
<?php echo $test->workingtime; ?>

</td>
<td>
<?PHP echo $test->tries ?>
</td>
<td></td>

</tr>
<?php } ?>
</tbody>
</table>

我正在尝试从数据库获取输出,但收到类似“PHP 错误”的错误 我正在尝试从数据库获取输出,但收到类似“遇到 PHP 错误”的错误 我正在尝试从数据库获取输出,但收到类似“PHP 错误”的错误遇到了。

消息:未定义的属性:stdClass::$workingtime。在 $workingtime 附近查看时出现错误

最佳答案

我认为您可能无法在模型响应中获取 workingtime 字段。重新检查您的 SQL 查询。

关于php - 收到错误未定义的属性:stdClass::$workingtime,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49248956/

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