mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
add namespace
This commit is contained in:
parent
374df89a4f
commit
8aef22ed74
2 changed files with 10 additions and 10 deletions
|
|
@ -48,7 +48,7 @@ class Page
|
||||||
// Run database cleaner
|
// Run database cleaner
|
||||||
if ($this->config->history->timeout)
|
if ($this->config->history->timeout)
|
||||||
{
|
{
|
||||||
$this->app->database->cleanHistory(
|
$this->app->database->cleanPageHistory(
|
||||||
$this->config->history->timeout
|
$this->config->history->timeout
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -373,7 +373,7 @@ class Page
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ignore history record on same URL stored in DB
|
// Ignore history record on same URL stored in DB
|
||||||
if ($result = $this->app->database->getHistory(0, 1))
|
if ($result = $this->app->database->getPageHistory(0, 1))
|
||||||
{
|
{
|
||||||
if ($url == $result[0]->url)
|
if ($url == $result[0]->url)
|
||||||
{
|
{
|
||||||
|
|
@ -396,7 +396,7 @@ class Page
|
||||||
// Update history in the database
|
// Update history in the database
|
||||||
if ($this->config->history->enabled)
|
if ($this->config->history->enabled)
|
||||||
{
|
{
|
||||||
$this->app->database->addHistory(
|
$this->app->database->addPageHistory(
|
||||||
$url
|
$url
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ class Database
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->_database->query('
|
$this->_database->query('
|
||||||
CREATE TABLE IF NOT EXISTS "history"
|
CREATE TABLE IF NOT EXISTS "pageHistory"
|
||||||
(
|
(
|
||||||
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||||
"time" INTEGER NOT NULL,
|
"time" INTEGER NOT NULL,
|
||||||
|
|
@ -55,12 +55,12 @@ class Database
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addHistory(
|
public function addPageHistory(
|
||||||
string $url
|
string $url
|
||||||
): int
|
): int
|
||||||
{
|
{
|
||||||
$query = $this->_database->prepare(
|
$query = $this->_database->prepare(
|
||||||
'INSERT INTO `history` (`time`, `url`) VALUES (:time, :url)'
|
'INSERT INTO `pageHistory` (`time`, `url`) VALUES (:time, :url)'
|
||||||
);
|
);
|
||||||
|
|
||||||
$query->execute(
|
$query->execute(
|
||||||
|
|
@ -73,14 +73,14 @@ class Database
|
||||||
return (int) $this->_database->lastInsertId();
|
return (int) $this->_database->lastInsertId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHistory(
|
public function getPageHistory(
|
||||||
int $start = 0,
|
int $start = 0,
|
||||||
int $limit = 1000
|
int $limit = 1000
|
||||||
): array
|
): array
|
||||||
{
|
{
|
||||||
$query = $this->_database->query(
|
$query = $this->_database->query(
|
||||||
sprintf(
|
sprintf(
|
||||||
'SELECT * FROM `history` ORDER BY `id` DESC LIMIT %d,%d',
|
'SELECT * FROM `pageHistory` ORDER BY `id` DESC LIMIT %d,%d',
|
||||||
$start,
|
$start,
|
||||||
$limit
|
$limit
|
||||||
)
|
)
|
||||||
|
|
@ -90,13 +90,13 @@ class Database
|
||||||
return $query->fetchAll();
|
return $query->fetchAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cleanHistory(
|
public function cleanPageHistory(
|
||||||
int $timeout = 0
|
int $timeout = 0
|
||||||
): int
|
): int
|
||||||
{
|
{
|
||||||
$query = $this->_database->query(
|
$query = $this->_database->query(
|
||||||
sprintf(
|
sprintf(
|
||||||
'DELETE FROM `history` WHERE `time` + %d < %d',
|
'DELETE FROM `pageHistory` WHERE `time` + %d < %d',
|
||||||
$timeout,
|
$timeout,
|
||||||
time()
|
time()
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue