codeigniter 3 limit

$this->db->limit($limit);
$query = $this->db->get('your_table');
return $query->result();
  1. $this->db->limit($limit); - Sets the limit for the number of rows to retrieve in the database query. Replace $limit with the desired number of rows to be retrieved.

  2. $query = $this->db->get('your_table'); - Executes the query on the specified table ('your_table') using the set limit and retrieves the data accordingly.

  3. return $query->result(); - Returns the result set obtained from the executed query, limited to the specified number of rows.