Almost done, just the answer system and query is missing

Took 4 hours 10 minutes
This commit is contained in:
2020-10-02 16:23:04 +02:00
parent c37ad92dbc
commit 8559e3388d
18 changed files with 1569 additions and 87 deletions

View File

@ -32,14 +32,26 @@ class DefaultModel
public function createRoom(string $room_name)
{
$room_owner = session_id();
$stmnt = Database::getConnection()->prepare( 'INSERT INTO rooms ( name, owner, code ) VALUES ( :name, :owner, :code )' );
$stmnt->execute( array( 'name' => $room_name, 'owner' => $room_owner, 'code' => $this->generateRandomStr() ) );
$stmnt = Database::getConnection()->prepare( 'INSERT INTO rooms ( name, owner_sid, code ) VALUES ( :name, :owner, :code )' );
$stmnt->execute( array( 'name' => $room_name, 'owner' => $room_owner, 'code' => $this->generateRandomStr( CODE_LENGTH ) ) );
$id = Database::getConnection()->lastInsertId( );
if( empty( $id ) )
{
return false;
}
return $id;
}
public function generateRandomStr( $length = 4 )
{
return 'U2HA';
$characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}