public function registerCategoryIfDoesntExist() { $db = new Database('blog'); $category = $db->prepare("SELECT * FROM categories WHERE name = ?", [$this->name], "App\\Table\\Categories", true); if ($category == null) { $category = ucfirst($category); $db->insert("\n\t\t\t\t\tINSERT INTO categories(name)\n\t\t\t\t\tVALUES(:name)\n\t\t\t\t", array("name" => $this->name)); } }
public static function register($username, $email, $password) { $db = new Database('blog'); $app = \App\App::getInstance(); $username = $app::destroyHTML($_POST['username']); $email = $app::destroyHTML($_POST['email']); $password = password_hash($app::destroyHTML($_POST['password']), PASSWORD_DEFAULT); $db->insert("INSERT INTO users(username,password,email) VALUES(:username,:password,:email)", array("username" => $username, "password" => $password, "email" => $email)); $app::redirect("index.php?page=welcome®ister=success"); }
/** * Run the database seeds. * * @return void */ public function run() { Database::truncate(); $data = [['server_id' => 1, 'name' => 'QGLAccount', 'username' => 'sa', 'password' => '123456'], ['server_id' => 1, 'name' => 'QGLGame', 'username' => 'sa', 'password' => '123456']]; Database::insert($data); }