I need to get only 1 record from sql result. we use "SELECT TOP 1" in standard sql, but how can we do that in CodeIgniter? Is there any func for that? I researched so much on net, but could not find :/
appreciate! thanks,
with LIMIT
$this->db->limit(1);
$query = $this->db->get('my_table');
$myRow = $query->row();
with OFFSET and LIMIT
$query = $this->db->get('mytable', 0, 1);
$myRow = $query->row();
Use
$this->db->limit(1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With