mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 09:05:27 +00:00
refactor to separated entities, init abstractions
This commit is contained in:
parent
08c9fe76e5
commit
90acc3ac2d
47 changed files with 1927 additions and 2069 deletions
|
|
@ -64,8 +64,8 @@ class Database
|
|||
return (int) $this->_database->lastInsertId();
|
||||
}
|
||||
|
||||
public function getHistory(
|
||||
string $search = '',
|
||||
public function findHistory(
|
||||
string $value = '',
|
||||
int $start = 0,
|
||||
int $limit = 1000
|
||||
): array
|
||||
|
|
@ -73,7 +73,7 @@ class Database
|
|||
$query = $this->_database->prepare(
|
||||
sprintf(
|
||||
'SELECT * FROM `history`
|
||||
WHERE `url` LIKE :search OR `title` LIKE :search
|
||||
WHERE `url` LIKE :value OR `title` LIKE :value
|
||||
ORDER BY `id` DESC
|
||||
LIMIT %d,%d',
|
||||
$start,
|
||||
|
|
@ -83,9 +83,9 @@ class Database
|
|||
|
||||
$query->execute(
|
||||
[
|
||||
':search' => sprintf(
|
||||
':value' => sprintf(
|
||||
'%%%s%%',
|
||||
$search
|
||||
$value
|
||||
)
|
||||
]
|
||||
);
|
||||
|
|
@ -122,4 +122,35 @@ class Database
|
|||
|
||||
return $query->rowCount();
|
||||
}
|
||||
|
||||
public function refreshHistory(
|
||||
string $url,
|
||||
?string $title = null
|
||||
): void
|
||||
{
|
||||
// Find same records match URL
|
||||
$query = $this->_database->prepare(
|
||||
'SELECT * FROM `history` WHERE `url` LIKE :url'
|
||||
);
|
||||
|
||||
$query->execute(
|
||||
[
|
||||
':url' => $url
|
||||
]
|
||||
);
|
||||
|
||||
// Drop previous records
|
||||
foreach ($query->fetchAll() as $record)
|
||||
{
|
||||
$this->deleteHistory(
|
||||
$record->id
|
||||
);
|
||||
}
|
||||
|
||||
// Add new record
|
||||
$this->addHistory(
|
||||
$url,
|
||||
$title
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue