<?php
class DataBase {
private static $database_name;
private static $mysqli;
public function __construct($database_name = '')
{
$hostname_connect = 'localhost';
$database_conntect = 'webdb';
$username_connect = 'root';
$password_connect = 'root';
$this->database_name = $database_name;
$this->mysqli = new mysqli(
$hostname_connect,
$username_connect,
$password_connect,
$database_conntect
);
@mysql_query("set_character_set_client='utf8'");
@mysql_query("set_character_set_results='utf8'");
@mysql_query("set collation_connection='utf8_unicode_ci'");
}
public function add_user($login='', $email='', $password=''){
// DEBUG
echo "INSERT INTO '$this->database_name' (login, email, password) VALUES ('$login', '$email', '$password')";
$this->mysqli->query("INSERT INTO '$this->database_name' (login, email, password) VALUES ('$login', '$email', '$password')");
}
public function user_is_exist($email= ''){
$result = $this->mysqli->query("SELECT * FROM '$this->database_name' WHERE email LIKE '$email' ");
$num_rows = mysqli_num_rows($result);
if($num_rows == false) {
return false;
}
else return true;
}
}
$a = new DataBase('test');
$a->add_user('test' , 'test' , 'test');
// INSERT INTO 'test' (login, email, password) VALUES ('test', 'test', 'test')
все работает корректно
смотрите то что выдаст вам строка
echo "INSERT INTO '$this->database_name' (login, email, password) VALUES ('$login', '$email', '$password')";
а лучше покажите как используете это вы