Skip to content

Instantly share code, notes, and snippets.

@stoddsie
Last active December 15, 2015 22:59
Show Gist options
  • Save stoddsie/5336780 to your computer and use it in GitHub Desktop.
Save stoddsie/5336780 to your computer and use it in GitHub Desktop.
Codeigniter:Retrieve single row from database
//Setup a database connection returning a single row value
$this->db->select("*");
$this->db->where("field", $value);
$query = $this->db->get("table",1,0);
if($query->num_rows() > 0) {
$variable = $query->row("field");
return $variable;
} else {
return FALSE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment