CodeIgniter - return only one row?
Asked 07 September, 2021
Viewed 947 times
  • 62
Votes

At the moment if I am doing a query on the database that should only return one row, using:

...query stuff...
$query = $this->db->get();
$ret = $query->result();
return $ret[0]->campaign_id;

Is there a CodeIgniter function to return the first row? something like $query->row();

Or even better would be the ability to, if there was only one row, to just use the query object directly.

e.g. $query->campaign_id;

11 Answer