By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,748 Members | 1,570 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,748 IT Pros & Developers. It's quick & easy.

function hide_old_news()

P: n/a
This function should set news_status field to 0 in expired newsitems, but it
doesnt seem to have any effect.
Expiration data is in "natural format" , news_year can be 2004, news_month 4
and so on. I checked the database today and one row has values 2004, 3, 1
meaning it should have become expired in last month. I tried to make it
expire today with this version of the function, but no. There is small(?)
chance that in the middle of debugging and database manipulation i made some
mistake but...

- perttu p, finland

function hide_old_news()
{
$date_info = getdate();
$y = $date_info['year'];
$m = $date_info['mon'];
$d = $date_info['mday'];

global $CFG;

$qid = "UPDATE $CFG->news SET news_status = 0
WHERE news_expire_year < $y
OR (news_expire_year = $y AND news_expire_month < $m)
OR (news_expire_year = $y AND news_expire_month < $m AND news_expire_date
<= $d)";
}
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Perttu Pulkkinen" <pe**************@co.jyu.fi> wrote:
This function should set news_status field to 0 in expired newsitems,
but it doesnt seem to have any effect. function hide_old_news()
{
$date_info = getdate();
$y = $date_info['year'];
$m = $date_info['mon'];
$d = $date_info['mday'];

global $CFG;

$qid = "UPDATE $CFG->news SET news_status = 0
WHERE news_expire_year < $y
OR (news_expire_year = $y AND news_expire_month < $m)
OR (news_expire_year = $y AND news_expire_month < $m AND
news_expire_date
<= $d)";
}


Hi Perttu,

You don't seem to execute the SQL statement.

HTH;
JOn
Jul 17 '05 #2

P: n/a
"Perttu Pulkkinen" <pe**************@co.jyu.fi> wrote in message
news:sI**************@read3.inet.fi...
This function should set news_status field to 0 in expired newsitems, but it doesnt seem to have any effect.
Expiration data is in "natural format" , news_year can be 2004, news_month 4 and so on. I checked the database today and one row has values 2004, 3, 1
meaning it should have become expired in last month. I tried to make it
expire today with this version of the function, but no. There is small(?)
chance that in the middle of debugging and database manipulation i made some mistake but...

- perttu p, finland

function hide_old_news()
{
$date_info = getdate();
$y = $date_info['year'];
$m = $date_info['mon'];
$d = $date_info['mday'];

global $CFG;

$qid = "UPDATE $CFG->news SET news_status = 0
WHERE news_expire_year < $y
OR (news_expire_year = $y AND news_expire_month < $m)
OR (news_expire_year = $y AND news_expire_month < $m AND news_expire_date <= $d)";
}


In addition to Jon's comment, your third set of conditions should be
checking for an equal month.

- Virgil
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.