Welcome Guest, Not a member yet? Register   Sign In
Update Link Visits
#1

[eluser]lotec[/eluser]
What is the simplest way to implement link visit counter within ci? I've done it before by passing link id to function that handled db entry and then redirected. A little confused in how to do it within ci framework. Nothing overly fancy, just want to know how many times a link has been clicked...simple as that, no ip, etc...
#2

[eluser]David Johansson[/eluser]
You could do the same as before, but put the function in a calss in a model.
#3

[eluser]Phil Sturgeon[/eluser]
Something like:

Code:
function add_visit($id) {
        $this->db->update('links', 'visits = visits + 1', array('id' => $id));
        return ($this->db->affected_rows() > 0);
    }

That will update it by 1 and give you a true/false response over whether or not it actually did anything.
#4

[eluser]jcavard[/eluser]
[quote author="Phil Sturgeon" date="1249911398"]Something like:
Code:
return ($this->db->affected_rows() > 0);
[/quote]

that's clever. I like that
#5

[eluser]jcavard[/eluser]
[quote author="Phil Sturgeon" date="1249911398"]Something like:
Code:
return ($this->db->affected_rows() > 0);
[/quote]

that's clever. I like that
#6

[eluser]lotec[/eluser]
Thanks Phil, that's what I'm talking about. Nice




Theme © iAndrew 2016 - Forum software by © MyBB