mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 01:25:27 +00:00
remove exception logic from model
This commit is contained in:
parent
84cc4899d7
commit
04eb93cf27
1 changed files with 25 additions and 38 deletions
|
|
@ -13,47 +13,34 @@ class Database
|
||||||
?string $username = null,
|
?string $username = null,
|
||||||
?string $password = null
|
?string $password = null
|
||||||
) {
|
) {
|
||||||
try
|
$this->_database = new \PDO(
|
||||||
{
|
sprintf(
|
||||||
$this->_database = new \PDO(
|
'sqlite:%s',
|
||||||
sprintf(
|
$database
|
||||||
'sqlite:%s',
|
),
|
||||||
$database
|
$username,
|
||||||
),
|
$password
|
||||||
$username,
|
);
|
||||||
$password
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->_database->setAttribute(
|
$this->_database->setAttribute(
|
||||||
\PDO::ATTR_ERRMODE,
|
\PDO::ATTR_ERRMODE,
|
||||||
\PDO::ERRMODE_EXCEPTION
|
\PDO::ERRMODE_EXCEPTION
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->_database->setAttribute(
|
$this->_database->setAttribute(
|
||||||
\PDO::ATTR_DEFAULT_FETCH_MODE,
|
\PDO::ATTR_DEFAULT_FETCH_MODE,
|
||||||
\PDO::FETCH_OBJ
|
\PDO::FETCH_OBJ
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->_database->query('
|
$this->_database->query('
|
||||||
CREATE TABLE IF NOT EXISTS "history"
|
CREATE TABLE IF NOT EXISTS "history"
|
||||||
(
|
(
|
||||||
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||||
"time" INTEGER NOT NULL,
|
"time" INTEGER NOT NULL,
|
||||||
"url" VARCHAR(1024) NOT NULL,
|
"url" VARCHAR(1024) NOT NULL,
|
||||||
"title" VARCHAR(255)
|
"title" VARCHAR(255)
|
||||||
)
|
)
|
||||||
');
|
');
|
||||||
}
|
|
||||||
|
|
||||||
catch (\PDOException $exception)
|
|
||||||
{
|
|
||||||
exit(
|
|
||||||
print_r(
|
|
||||||
$exception->getMessage(),
|
|
||||||
true
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addHistory(
|
public function addHistory(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue