|
|
@ -34,7 +34,7 @@ class Database |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
$this->_database->query(' |
|
|
|
$this->_database->query(' |
|
|
|
CREATE TABLE IF NOT EXISTS "history" |
|
|
|
CREATE TABLE IF NOT EXISTS "browser_page_history" |
|
|
|
( |
|
|
|
( |
|
|
|
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, |
|
|
|
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, |
|
|
|
"time" INTEGER NOT NULL, |
|
|
|
"time" INTEGER NOT NULL, |
|
|
@ -44,13 +44,13 @@ class Database |
|
|
|
'); |
|
|
|
'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function addHistory( |
|
|
|
public function addBrowserPageHistory( |
|
|
|
string $url, |
|
|
|
string $url, |
|
|
|
?string $title = null |
|
|
|
?string $title = null |
|
|
|
): int |
|
|
|
): int |
|
|
|
{ |
|
|
|
{ |
|
|
|
$query = $this->_database->prepare( |
|
|
|
$query = $this->_database->prepare( |
|
|
|
'INSERT INTO `history` (`time`, `url`, `title`) VALUES (:time, :url, :title)' |
|
|
|
'INSERT INTO `browser_page_history` (`time`, `url`, `title`) VALUES (:time, :url, :title)' |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
$query->execute( |
|
|
|
$query->execute( |
|
|
@ -64,7 +64,7 @@ class Database |
|
|
|
return (int) $this->_database->lastInsertId(); |
|
|
|
return (int) $this->_database->lastInsertId(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function findHistory( |
|
|
|
public function findBrowserPageHistory( |
|
|
|
string $value = '', |
|
|
|
string $value = '', |
|
|
|
int $start = 0, |
|
|
|
int $start = 0, |
|
|
|
int $limit = 1000 |
|
|
|
int $limit = 1000 |
|
|
@ -72,7 +72,7 @@ class Database |
|
|
|
{ |
|
|
|
{ |
|
|
|
$query = $this->_database->prepare( |
|
|
|
$query = $this->_database->prepare( |
|
|
|
sprintf( |
|
|
|
sprintf( |
|
|
|
'SELECT * FROM `history` |
|
|
|
'SELECT * FROM `browser_page_history` |
|
|
|
WHERE `url` LIKE :value OR `title` LIKE :value |
|
|
|
WHERE `url` LIKE :value OR `title` LIKE :value |
|
|
|
ORDER BY `id` DESC |
|
|
|
ORDER BY `id` DESC |
|
|
|
LIMIT %d,%d', |
|
|
|
LIMIT %d,%d', |
|
|
@ -93,13 +93,13 @@ class Database |
|
|
|
return $query->fetchAll(); |
|
|
|
return $query->fetchAll(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function deleteHistory( |
|
|
|
public function deleteBrowserPageHistory( |
|
|
|
int $id |
|
|
|
int $id |
|
|
|
): int |
|
|
|
): int |
|
|
|
{ |
|
|
|
{ |
|
|
|
$query = $this->_database->query( |
|
|
|
$query = $this->_database->query( |
|
|
|
sprintf( |
|
|
|
sprintf( |
|
|
|
'DELETE FROM `history` WHERE `id` = %d', |
|
|
|
'DELETE FROM `browser_page_history` WHERE `id` = %d', |
|
|
|
$id |
|
|
|
$id |
|
|
|
) |
|
|
|
) |
|
|
|
); |
|
|
|
); |
|
|
@ -107,13 +107,13 @@ class Database |
|
|
|
return $query->rowCount(); |
|
|
|
return $query->rowCount(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function cleanHistory( |
|
|
|
public function cleanBrowserPageHistory( |
|
|
|
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 `browser_page_history` WHERE `time` + %d < %d', |
|
|
|
$timeout, |
|
|
|
$timeout, |
|
|
|
time() |
|
|
|
time() |
|
|
|
) |
|
|
|
) |
|
|
@ -123,14 +123,14 @@ class Database |
|
|
|
return $query->rowCount(); |
|
|
|
return $query->rowCount(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function renewHistory( |
|
|
|
public function renewBrowserPageHistory( |
|
|
|
string $url, |
|
|
|
string $url, |
|
|
|
?string $title = null |
|
|
|
?string $title = null |
|
|
|
): void |
|
|
|
): void |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Find same records match URL |
|
|
|
// Find same records match URL |
|
|
|
$query = $this->_database->prepare( |
|
|
|
$query = $this->_database->prepare( |
|
|
|
'SELECT * FROM `history` WHERE `url` LIKE :url' |
|
|
|
'SELECT * FROM `browser_page_history` WHERE `url` LIKE :url' |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
$query->execute( |
|
|
|
$query->execute( |
|
|
@ -142,13 +142,13 @@ class Database |
|
|
|
// Drop previous records |
|
|
|
// Drop previous records |
|
|
|
foreach ($query->fetchAll() as $record) |
|
|
|
foreach ($query->fetchAll() as $record) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$this->deleteHistory( |
|
|
|
$this->deleteBrowserPageHistory( |
|
|
|
$record->id |
|
|
|
$record->id |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Add new record |
|
|
|
// Add new record |
|
|
|
$this->addHistory( |
|
|
|
$this->addBrowserPageHistory( |
|
|
|
$url, |
|
|
|
$url, |
|
|
|
$title |
|
|
|
$title |
|
|
|
); |
|
|
|
); |
|
|
|