My solution to this problem consisted of a combination of jondavidjohn's answer and mkoistinen's comment.
According to the CodeIgniter documentation:
You can also pass a string to result() which represents a class to
instantiate for each result object (note: this class must be loaded)
Armed with that knowledge, we can rewrite jondavidjohn's solution in this way:
class Blogmodel extends CI_Model {
var $title = '';
var $content = ''; // Declare Class wide Model properties
var $date = '';
function __construct()
{
// Call the Model constructor
parent::__construct();
}
function get_entry()
{
$query = $this->db->query('query to get single object');
$blogModel = $query->row('Blogmodel'); //Get single record
return $blogModel; //Return the Model instance
}
}
function get_entry($id) { return $this->db->where('id', $id)->get('blog_table')->row(0, "Blogmodel"); }
? – Lattimore