Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class DB
- {
- // объявление свойства
- protected $host = 'localhost';
- protected $db = 'loadbot_db'; // имя базы
- protected $charset = 'utf8';
- protected $user = 'cvr55'; // имя юзера
- protected $pass = 'DDee44rr55'; // пароль юзера
- public function __construct() {
- $dsn = "mysql:host=$this->host;dbname=$this->db;charset=$this->charset";
- $opt = array(
- PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
- PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
- );
- try {
- $this->DBconnect = new PDO($dsn, $this->user, $this->pass, $opt);
- }
- catch( PDOException $Exception ) {
- echo $Exception->getMessage();
- echo $Exception->getCode();
- if(!empty($Exception->getCode())){
- die('Ошибка');
- }
- }
- }
- // проверка на URL
- public function printHello() {
- echo $this->host.'<br>';
- echo $this->db.'<br>';
- }
- // проверка на наличие e-mail в базе 0 - нет, иначе да
- public function checkDoubleMail($table, $column, $email) {
- // Проверим есть ли такой юзер
- $auth = $this->DBconnect->prepare('SELECT COUNT(*) FROM `'.$table.'` WHERE `'.$column.'`=:mail');
- $auth->bindParam(':'.$column, $email, PDO::PARAM_STR);
- $auth->execute();
- $Count = $auth->fetchAll();
- return intval(implode('', $Count[0]));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement