[pLog-svn] r3354 - plog/trunk/class/summary/dao

Jon Daley plogworld at jon.limedaley.com
Sun May 7 12:29:33 GMT 2006


 	The query changed in rev 3234.  It used to do getTimeStamp() which 
also returns the time as part of the variable, now it just returns the 
day.  The old code is still commented out in the current function.
 	A user has complained about this on bugs.lifetype.

On Sun, 7 May 2006, Oscar Renalias wrote:

> The problem with NOW() is that we should avoid SQL functions in queries, as 
> it makes it impossible for mysql to optimize its queries better. Or at least 
> that's what I noticed.
>
> Are you sure it doesn't work? It's just doing the same stuff we've been doing 
> since at least LT 1.0.2...
>
> Oscar
>
> On 6 May 2006, at 23:33, jondaley at devel.lifetype.net wrote:
>
>> Author: jondaley
>> Date: 2006-05-06 20:33:52 +0000 (Sat, 06 May 2006)
>> New Revision: 3354
>> 
>> Modified:
>>   plog/trunk/class/summary/dao/summarystats.class.php
>> Log:
>> rev 3234 seems to have broken a bunch of things.  The recent article 
>> timestamp checking was wrong - there isn't a timestamp included in the _now 
>> variable, only a date, so articles don't show on the summary until the next 
>> day.  I fixed the only one that I can test, I imagine they are all broken? 
>> Is there any reason to not use NOW() in the sql query instead of 
>> pre-calculating the value?
>> 
>> Modified: plog/trunk/class/summary/dao/summarystats.class.php
>> ===================================================================
>> --- plog/trunk/class/summary/dao/summarystats.class.php	2006-05-06 
>> 18:53:28 UTC (rev 3353)
>> +++ plog/trunk/class/summary/dao/summarystats.class.php	2006-05-06 
>> 20:33:52 UTC (rev 3354)
>> @@ -39,11 +39,11 @@
>>
>>             // calculate the date limits
>>             $t = new Timestamp();
>> -            //$this->_now = $t->getTimestamp();
>> -			$this->_now = $t->getYear().$t->getMonth();
>> +                //$this->_now = $t->getTimestamp();
>> +            $this->_now = $t->getYear().$t->getMonth();
>> 			if( $t->getDay() < 10 )
>> 				$this->_now .= "0";
>> -			$this->_now .= $t->getDay();			+ 
>> $this->_now .= $t->getDay();
>>             // 7 days ago
>>             $t->subtractSeconds( 7 * 24 * 60 * 60 );
>>             //$this->_sevenDaysAgo = $t->getTimestamp();
>> @@ -251,14 +251,12 @@
>>             include_once( PLOG_CLASS_PATH . 
>> "class/data/timestamp.class.php" );
>>             include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
>> 
>> -            $t      = new Timestamp();
>> -            $date   = $t->getTimestamp();
>> 			$prefix = $this->getPrefix();
>>
>> 			$query = "SELECT a.*
>> 					  FROM {$prefix}articles a,
>> 					       {$prefix}blogs b
>> -					  WHERE a.date >= 
>> ".$this->_sevenDaysAgo." AND a.date <= ".$this->_now."
>> +					  WHERE a.date >= 
>> ".$this->_sevenDaysAgo." AND a.date <= NOW()
>> 					        AND a.blog_id = b.id
>> 					        AND b.status = 
>> ".BLOG_STATUS_ACTIVE."
>> 					        AND a.status = 
>> ".POST_STATUS_PUBLISHED."
>> @@ -312,8 +310,6 @@
>>             include_once( PLOG_CLASS_PATH . 
>> "class/data/timestamp.class.php" );
>>             include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
>> 
>> -            $t      = new Timestamp();
>> -            $date   = $t->getTimestamp();
>> 			$prefix = $this->getPrefix();
>>
>> 			$query = "SELECT a.id as id, MAX(a.date) as date
>> @@ -352,8 +348,6 @@
>>             include_once( PLOG_CLASS_PATH . 
>> "class/data/timestamp.class.php" );
>>             include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
>> 
>> -            $t      = new Timestamp();
>> -            $date   = $t->getTimestamp();
>> 			$prefix = $this->getPrefix();
>>
>> 			$query = "SELECT a.*
>> 
>> _______________________________________________
>> pLog-svn mailing list
>> pLog-svn at devel.lifetype.net
>> http://devel.lifetype.net/mailman/listinfo/plog-svn
>> 
>
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.lifetype.net
> http://devel.lifetype.net/mailman/listinfo/plog-svn

**************************************
Jon Daley
http://jon.limedaley.com/

If the person you are talking to doesn't appear to be
listening, be patient.  It may simply be that he has
a small piece of fluff in his ear.
-- Pooh's Little Instruction Book


More information about the pLog-svn mailing list