Skip to content

Instantly share code, notes, and snippets.

@rubdottocom
Created May 8, 2012 08:47
Show Gist options
  • Save rubdottocom/2633648 to your computer and use it in GitHub Desktop.
Save rubdottocom/2633648 to your computer and use it in GitHub Desktop.
CodeIgniter: Select from database function
public function get_ENTITY_by_FIELD($field)
{
log_message('debug', __METHOD__);
$columns = array(
$this->id
);
$result =
$this->db
->select($columns)
->from($this->table)
->where($this->field, $field)
->get();
if (!$result) $this->common->log_database_error($this->db->last_query(), $this->db->_error_message(), $this->db->_error_number());
return $result->result_array();
}
@rubdottocom
Copy link
Author

log_database_error: https://gist.github.com/2633658

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment