有没有一种方法可以获取数据库中的最后一个插入数据组? Codeigniter

问题描述 投票:0回答:1

我需要获取数字或数据组,如何实现?

为了可视化,这是图像

enter image description here

如何获取突出显示的数据,而不是未突出显示的数据。

现在,我的问题是,我只能获取未在图像中突出显示的数据。

这是我的模型及其使用的查询。

如您所见,我对日期进行了硬编码,因此可以获取所需的数据。但是仍然如何修改它,这样我就不会使用硬编码数据。

public function view_results($id){
    $this->db->select('*');
    $this->db->from('results');
    $this->db->where('student_id', $id);
    $this->db->where('post_id', $this->input->post('postId'));
    $this->db->where('date_answered', '2020-03-26 19:27:18');
    $this->db->group_by('question');
    $query = $this->db->get();
    return $result = $query->result_array();
}
php codeigniter codeigniter-3
1个回答
0
投票

我想您需要为每次尝试解决测试的操作添加唯一的尝试ID。然后,您将基于此尝试ID选择所有行。

© www.soinside.com 2019 - 2024. All rights reserved.