我正在尝试从数据库获取输出但是遇到错误,就像遇到了PHP错误一样 严重性:注意
消息:未定义属性:stdClass :: $ workingtime下面是我的code.with控制器,模型和view.getting错误在$ workingtime附近的视图
控制器:
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附近查看错误
答案 0 :(得分:0)
我认为您可能无法在模型响应中获得workingtime
字段。重新检查您的SQL查询。