Created
May 17, 2017 12:21
-
-
Save mrcat323/a28016fde9b1ea47b43a06acd97c6451 to your computer and use it in GitHub Desktop.
lil' db class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Find bugs and tell me!