本文整理汇总了PHP中Archive::deleteOldRecords方法的典型用法代码示例。如果您正苦于以下问题:PHP Archive::deleteOldRecords方法的具体用法?PHP Archive::deleteOldRecords怎么用?PHP Archive::deleteOldRecords使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Archive
的用法示例。
在下文中一共展示了Archive::deleteOldRecords方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteOldRecords
function deleteOldRecords()
{
parent::deleteOldRecords();
// delete records in VISIT that are useless
// (means when week AND month using these records are archived)
if (($this->periodType === DB_ARCHIVES_PERIOD_MONTH || $this->periodType === DB_ARCHIVES_PERIOD_WEEK) && $this->state !== DB_ARCHIVES_TEMP) {
// select all weeks and months begin and end
$r = query("SELECT date1, date2, idsite, period, idarchives\n\t\t\t\t\t\tFROM " . T_ARCHIVES . "\n\t\t\t\t\t\tWHERE done = " . DB_ARCHIVES_DONE . "\n\t\t\t\t\t\t\tAND (period = " . DB_ARCHIVES_PERIOD_WEEK . "\n\t\t\t\t\t\t\t\tOR period = " . DB_ARCHIVES_PERIOD_MONTH . "\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t");
while ($l = mysql_fetch_assoc($r)) {
// stock all dates between these two in an array
$dateBetween = getDaysBetween($l['date1'], $l['date2']);
//print($l['idarchives'] ."<br>");
//print( $l['date1'].",". $l['date2']." id=:". $l['idsite']." period=:". $l['period']." " );
//print_r($dateBetween); print("<br> which is ".sizeof($dateBetween)." elements <br><br>");
if (isset($flag[$l['idsite']][$l['period']][$l['date1']])) {
$c = $flag[$l['idsite']][$l['period']][$l['date1']];
if (sizeof($c) < sizeof($dateBetween) && sizeof($dateBetween) >= 7) {
$flag[$l['idsite']][$l['period']][$l['date1']] = $dateBetween;
}
} else {
$flag[$l['idsite']][$l['period']][$l['date1']] = $dateBetween;
}
}
//exit;
foreach ($flag as $idsite => $a_idsite) {
foreach ($a_idsite as $period => $a_period) {
foreach ($a_period as $a_date) {
foreach ($a_date as $d) {
if (!isset($toCheck[$idsite][$d])) {
$toCheck[$idsite][$d] = 1;
} else {
$toCheck[$idsite][$d]++;
}
}
}
}
}
//print("<pre>Apres sommes des dates <br>");
//print_r($toCheck);
$deleted = 0;
foreach ($toCheck as $idsite => $a_date) {
foreach ($a_date as $date => $hits) {
// for the days who have 2 hits (mean that weeks and month that contain
// this day are archived)
// delete these day records!
if ($hits > 1) {
$r = query("DELETE\n\t\t\t\t\t\t\t\t\tFROM " . T_VISIT . "\n\t\t\t\t\t\t\t\t\tWHERE server_date = '" . $date . "'\n\t\t\t\t\t\t\t\t\t\tAND idsite = {$idsite}\n\t\t\t\t\t\t\t\t\t\t");
$deleted += mysql_affected_rows();
}
}
}
//print("rows deleted = $deleted");
if (time() % 3 == 0) {
$r = query("OPTIMIZE TABLE " . T_VISIT);
}
}
}
示例2: deleteOldRecords
function deleteOldRecords()
{
parent::deleteOldRecords();
if ($this->date->get() != getDateFromTimestamp(time())) {
if (version_compare(getMysqlVersion(), '4.0') != -1) {
$r = query("DELETE \n\t\t\t\t\t\t\tFROM " . T_LINK_VP . ", " . T_LINK_VPV . "\n\t\t\t\t\t\t\tUSING " . T_VISIT . "\n\t\t\t\t\t\t\t\tLEFT JOIN " . T_LINK_VP . "\n\t\t\t\t\t\t\t\tUSING ( idvisit )\n\t\t\t\t\t\t\t\tLEFT JOIN " . T_LINK_VPV . "\n\t\t\t\t\t\t\t\tUSING ( idlink_vp )\n\t\t\t\t\t\t\tWHERE " . T_VISIT . ".server_date = '" . $this->date->get() . "'\n\t\t\t\t\t\t \t\tAND " . T_VISIT . ".idsite = " . $this->site->getId() . "\n\t\t\t\t\t\t ");
} else {
// delete link_vp records
print "Your mysql version is less than 4.0, so this process will be very long \n\t\t\t\t(a big feature is not implemented in your 3.23 version). \n\t\t\t\t<br>You should use mysql 4.0 or mysql 4.1!<br>\n\t\t\t\t<br>Vous devriez utiliser mysql 4.0 ou supérieure pour plus de performances \n\t\t\t\t(une fonctionnalité très importante est manquante à votre version 3.23<br>";
// select all link_vp id
$r = query("SELECT idlink_vp\n\t\t\t\t\t\t\tFROM " . T_VISIT . "\n\t\t\t\t\t\t\t\tLEFT JOIN " . T_LINK_VP . "\n\t\t\t\t\t\t\t\tUSING ( idvisit )\n\t\t\t\t\t\t\tWHERE " . T_VISIT . ".server_date = '" . $this->date->get() . "'\n\t\t\t\t\t\t \t\tAND " . T_VISIT . ".idsite = " . $this->site->getId() . "\n\t\t\t\t\t\t \t\t");
while ($l = mysql_fetch_row($r)) {
if (!empty($l[0])) {
$r2 = query("DELETE FROM " . T_LINK_VP . "\n\t\t\t\t\t\t\t\tWHERE idlink_vp = " . $l[0]);
}
}
}
$r3 = query("OPTIMIZE TABLE " . T_LINK_VP . ", " . T_LINK_VPV);
}
}