|
|
@@ -0,0 +1,37 @@ |
|
|
|
<?php |
|
|
|
|
|
|
|
namespace Blog; |
|
|
|
|
|
|
|
use SQLite3; |
|
|
|
|
|
|
|
class DB extends SQLite3 |
|
|
|
{ |
|
|
|
function __construct() |
|
|
|
{ |
|
|
|
$this->open('../private/test.db'); |
|
|
|
} |
|
|
|
|
|
|
|
public function checkUserPass($user, $pass) |
|
|
|
{ |
|
|
|
$sql = "SELECT count(*) as count FROM users WHERE username = '" . $user . "' AND password = '" . $pass . "';"; |
|
|
|
$ret = $this->query($sql); |
|
|
|
$rows = $ret->fetchArray(SQLITE3_ASSOC); |
|
|
|
$rowcount = $rows['count']; |
|
|
|
if ($rowcount == 1) { |
|
|
|
return true; |
|
|
|
} else { |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public function createBlog($data) |
|
|
|
{ |
|
|
|
$this->enableExceptions(false); |
|
|
|
$stmt = $this->prepare("INSERT INTO blogs (slug, title, content) VALUES (:slug, :title, :content)"); |
|
|
|
$stmt->bindValue(':slug', $data['slug'], SQLITE3_TEXT); |
|
|
|
$stmt->bindValue(':title', $data['title'], SQLITE3_TEXT); |
|
|
|
$stmt->bindValue(':content', $data['content'], SQLITE3_TEXT); |
|
|
|
$res = $stmt->execute(); |
|
|
|
return $res; |
|
|
|
} |
|
|
|
} |