Skip to content

Instantly share code, notes, and snippets.

@mrcat323
Created May 17, 2017 12:21
Show Gist options
  • Save mrcat323/a28016fde9b1ea47b43a06acd97c6451 to your computer and use it in GitHub Desktop.
Save mrcat323/a28016fde9b1ea47b43a06acd97c6451 to your computer and use it in GitHub Desktop.
lil' db class
<?php
class DB {
public static function connectDb()
{
$host = 'localhost';
$dbname = 'hhahh';
$user = 'hhahh';
$password = 'hhahh';
$db = new PDO("mysql:host=$host;dbname=$dbname", $user, $password);
}
public static function check() {
$st = $db->prepare("SELECT `password` FROM `users` WHERE `login` = :login AND `password` = :password");
$st->bindValue(":login", $login, PDO::PARAM_STR);
$st->bindValue(":password", $password, PDO::PARAM_STR);
$st->execute();
$db = null;
}
public static function insert() {
$st = $db->prepare("INSERT INTO `users` (`login`, `password`) VALUES(:login, :password)");
$st->bindValue(":login", $login, PDO::PARAM_STR);
$st->bindValue(":password", $password, PDO::PARAM_STR);
$st->execute();
$db = null;
}
}
?>
@mrcat323
Copy link
Author

Find bugs and tell me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment