How To Count The Number Of Times A File Is Downloaded.

Hello guys.

I am using posts (just like in blog example) in my projects which contains some external files that is to be downloaded. Now I want to keep the record of the downloaded files in my database. So that I can show it on the post detail page.

I have used the savecounter() method with afterfind() method in Post model




protected function afterFind() {

        parent::afterFind();

        $this->_oldTags = $this->tags;

        $this->saveCounters(array('views'=>1));

        $this->saveCounters(array('hits'=>1));

    }



but it increased it once a post is viewed or loaded. but I want it to restrict it to only downloads. that I a post external file is downloaded then increase the post’s hit value. and one more thing that the savecounter() method increases the value by 6 nor by 1, so how to restrict it to 1 ?

How can I save the downloaded files record in my database ?

Thanks in advance.

To save the file: if one file per post, add a field(s) to the Post table.

More than 1 file: tbl_files, relation to tbl_post.

Download count: actionDownload() in PostController with something like xSend() to force SaveAs.

saveCounter(): I thought it was by one, but haven’t used…

thanks dear for your response.

Actually I am using a single post table to save the file and remaining post details.

And I want to save the record of those posts whose files are mostly downloaded.