ソースを参照

DB in one file, to be removed

Namespaces
Ruben De Baets 2年前
コミット
a2ee7ea36b
1個のファイルの変更37行の追加0行の削除
  1. 37
    0
      src/DB.php

+ 37
- 0
src/DB.php ファイルの表示

@@ -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;
}
}

読み込み中…
キャンセル
保存