mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 01:25:27 +00:00
update database model
This commit is contained in:
parent
ce1cabc3c7
commit
fa47610f65
1 changed files with 8 additions and 4 deletions
|
|
@ -6,17 +6,18 @@ namespace Yggverse\Yoda\Model;
|
||||||
|
|
||||||
class Database
|
class Database
|
||||||
{
|
{
|
||||||
public \PDO $_database;
|
private \PDO $_database;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
string $database,
|
string $filename,
|
||||||
?string $username = null,
|
?string $username = null,
|
||||||
?string $password = null
|
?string $password = null
|
||||||
) {
|
) {
|
||||||
|
// Init database
|
||||||
$this->_database = new \PDO(
|
$this->_database = new \PDO(
|
||||||
sprintf(
|
sprintf(
|
||||||
'sqlite:%s',
|
'sqlite:%s',
|
||||||
$database
|
$filename
|
||||||
),
|
),
|
||||||
$username,
|
$username,
|
||||||
$password
|
$password
|
||||||
|
|
@ -71,7 +72,10 @@ class Database
|
||||||
{
|
{
|
||||||
$query = $this->_database->prepare(
|
$query = $this->_database->prepare(
|
||||||
sprintf(
|
sprintf(
|
||||||
'SELECT * FROM `history` WHERE `url` LIKE :search OR `title` 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,
|
$start,
|
||||||
$limit
|
$limit
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue