Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: [Solved]: Show best rated this month is not working  (Read 3872 times)

0 Members and 1 Guest are viewing this topic.

Peter R

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 26
[Solved]: Show best rated this month is not working
« on: February 23, 2009, 02:53:23 pm »

Since I found cpmFetch, I started to use it everywhere in the site. Great piece of code.
Now I want to show best three rated images, only picture posted in this month. This seems not hard, but is for me.
I call cpmFetch with:
$objCpm->cpm_viewTopRatedMediaFrom("cat=28",1, 3, $options)
This works fine, but is givng me best rated of all pictures, and not from the ones only added this month. For that, I made a small change in cpmfetch_dao.php
In the function function getTopRatedMediaFrom, I changed:

. $this->sqlTableSelect
. " WHERE 1 "
. $this->sqlUserDataLink
. $this->filetypefilter ." AND p.approved='YES' "
. $sourceSql . " {$this->privacyfilter} "
. " ORDER BY p.pic_rating DESC LIMIT 0,$count";

Into:
. $this->sqlTableSelect
. " WHERE 1 "
. $this->sqlUserDataLink
. $this->filetypefilter ." AND p.approved='YES' "
. " AND EXTRACT(YEAR_MONTH FROM mtime) = EXTRACT(YEAR_MONTH FROM CURRENT_DATE)"               
. $sourceSql . " {$this->privacyfilter} "
. " ORDER BY p.pic_rating DESC LIMIT 0,$count";

It looks very easy, but it is not working. I even get results from the last year?!? There are no php ore mySql errors, so  I miss some understanding about the working of cpmFetch or Coppermine.

How can I get this working correct?
« Last Edit: February 23, 2009, 10:12:20 pm by Nibbler »
Logged

Nibbler

  • Guest
Re: Show best rated this month is not working
« Reply #1 on: February 23, 2009, 03:01:29 pm »

mtime is the last viewed time. You want to be using ctime which is the upload date/time (as unix timestamp).
Logged

Peter R

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 26
Re: Show best rated this month is not working
« Reply #2 on: February 23, 2009, 10:10:10 pm »

> mtime is the last viewed time. You want to be using ctime
> which is the upload date/time (as unix timestamp).
Ha ha, well, that explains a lot.
And oh, I do hate unix timestamp. Some day, somebody started counting seconds and called it a time stamp.
Well, there is an advantage: this can easely be used to calculate GMT/UCT time. And because this gallery is multi continent, I want to keep it al GMT/UTC.

To complete this post:
In stead of my:
. " AND EXTRACT(YEAR_MONTH FROM mtime) = EXTRACT(YEAR_MONTH FROM CURRENT_DATE)"
use:
. " AND ctime > " . $timestamp

Above the line with $sqlcode = ......
put:
$timestamp = strtotime(gmdate("01-m-Y"));

Thanks for putting me on the right track.
Logged
Pages: [1]   Go Up
 

Page created in 0.035 seconds with 20 queries.