[eluser]Freeze Dried Pop[/eluser]
Is it possible, or has anyone made an add on, that allows for the registering of queries to run on script shutdown?
For instance, when viewing an article I may want to add to the database that a specific user has read an article, increment the hit count for that article and mark a user being "online now".
That's three queries which don't need to be run in order to display the page, so i'd rather get it out to the user and then run it.
Now I realise I could do something like this (poorly written I know, its just an example):
Code:
class blog {
function article()
{
$article = get_article(uri_segment(3));
$this->load->view('article', $article);
$this->db->query('INSERT INTO online_now VALUES ('.$session_id.', '.time().')');
$this->db->query('INSERT INTO article_read VALUES ('.$user_id.', '.time().')');
$this->db->query('UPDATE article SET article_hits = article_hits+1 WHERE article_id = '.$article->id);
}
}
But this requires the controller doing all the work, i'd rather be able to set queries to run on shutdown from within library functions.
Is this possible or has anyone done anything similar? If not i'm sure I can knock something up myself but thought i'd ask anyway.