if ($_SERVER['REMOTE_ADDR'] == '127.0.0.1') {
$host = 'localhost';
$name = 'voynushka';
$char = 'utf8mb4';
$user = 'mysql';
$pass = 'mysql';
} else {
$host = '';
$name = '';
$char = '';
$user = '';
$pass = '';
}
$this->connect = Db::setup($host, $name, $char, $user, $pass, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ
]);
class Db
{
private static $instance;
private function __construct($host, $name, $char, $user, $pass, $opt)
{
self::$instance = new PDO("mysql:host={$host};dbname={$name};charset={$char}", $user, $pass, $opt);
}
public static function setup($host, $name, $char, $user, $pass, $opt = [])
{
if (is_null(self::$instance)) {
new self($host, $name, $char, $user, $pass, $opt);
}
return self::$instance;
}
}
abstract class Model
{
protected $connect;
public function __construct()
{
$this->connect = Db::setup($host, $name, $char, $user, $pass, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ
]);
}
}
`no_credits` = if(`email` = '$email_i',$get_balanse_cred, `no_credits`)