battles/classes/Battles/Register.php

21 lines
886 B
PHP
Raw Normal View History

<?php
namespace Battles;
use Battles\Database\Db;
class Register
{
public static function addUser(string $login, string $password, string $email, string $birthday): int
{
if (Db::getInstance()->execute('select count(*) from users where login = ? or email = ?', [$login, $email])->fetchColumn()) {
return 0;
}
Db::getInstance()->execute('insert into users (login,pass,email,borndate,ip,session_id,shadow) values (?,?,?,?,?,?,?)',
[$login, $password, $email, $birthday, $_SERVER['REMOTE_ADDR'], session_id(), '0.png']);
$userId = Db::getInstance()->lastInsertId();
Db::getInstance()->execute('insert into online (user_id, login_time, room, real_time) values (?,?,1,?)', [$userId, time(), time()]);
Db::getInstance()->execute('insert into bank (user_id) values ?', $userId);
return $userId;
}
}