在php中相同的时间戳下降条件

I have given some timestamp condition descending , but if all timestamp are equals then descending condition is not working . It's returning the first row only, I need the last row.

below is code

         $this->db->like("time_stamp",$_POST['date'],"after");
         $this->db->order_by("time_stamp DESC");
         $this->db->limit("1");
         $query5= $this->db->get_where("report",array("student_id" => $student_id));

Please check table screenshot.

enter image description here

I need the last row ,not the first . here timestamp is same , so its not coming .

is there any way to do it ??

You cannot do further sorting when the data is exactly the same. What you can do is set a 2nd criteria when data is the same, it'll continue to the second criteria for ordering.

Normally you use your ID value. If you want the latest added you can use the below.

 $this->db->order_by("time_stamp DESC");
 $this->db->order_by("id DESC"); // this is the new line in your code

If you want the earlier added you can use the below code.

$this->db->order_by("time_stamp DESC");
$this->db->order_by("id"); // by default is ASC

Another way is like this in 1 row

$this->db->order_by("time_stamp DESC, id DESC");

What you can do in this is add another order_by condition based on your PK for the table, e.g.

$this->db->order_by('time_stamp DESC, id DESC');

Can you do this, in your scenario?