mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 00:55:28 +00:00
save page title to the database history
This commit is contained in:
parent
eeceb7caaa
commit
7451d6d78f
3 changed files with 57 additions and 42 deletions
|
|
@ -37,9 +37,10 @@ class Database
|
|||
$this->_database->query('
|
||||
CREATE TABLE IF NOT EXISTS "history"
|
||||
(
|
||||
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
"time" INTEGER NOT NULL,
|
||||
"url" VARCHAR(1024) NOT NULL
|
||||
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
"time" INTEGER NOT NULL,
|
||||
"url" VARCHAR(1024) NOT NULL,
|
||||
"title" VARCHAR(255)
|
||||
)
|
||||
');
|
||||
}
|
||||
|
|
@ -56,17 +57,19 @@ class Database
|
|||
}
|
||||
|
||||
public function addHistory(
|
||||
string $url
|
||||
string $url,
|
||||
?string $title = null
|
||||
): int
|
||||
{
|
||||
$query = $this->_database->prepare(
|
||||
'INSERT INTO `history` (`time`, `url`) VALUES (:time, :url)'
|
||||
'INSERT INTO `history` (`time`, `url`, `title`) VALUES (:time, :url, :title)'
|
||||
);
|
||||
|
||||
$query->execute(
|
||||
[
|
||||
':time' => time(),
|
||||
':url' => $url
|
||||
':time' => time(),
|
||||
':url' => $url,
|
||||
':title' => $title
|
||||
]
|
||||
);
|
||||
|
||||
|
|
@ -81,7 +84,7 @@ class Database
|
|||
{
|
||||
$query = $this->_database->prepare(
|
||||
sprintf(
|
||||
'SELECT * FROM `history` WHERE `url` LIKE :search ORDER BY `id` DESC LIMIT %d,%d',
|
||||
'SELECT * FROM `history` WHERE `url` LIKE :search OR `title` LIKE :search ORDER BY `id` DESC LIMIT %d,%d',
|
||||
$start,
|
||||
$limit
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue