function create_roles()

in workshop/99_Miscellaneous/Refactoring/functions/database.php [47:58]


function create_roles($databaseConnection, $admin_role_id)
{
    $query_check_roles_exist = "SELECT id FROM roles WHERE id <= 2";
    $statement_check_roles_exist = $databaseConnection->prepare($query_check_roles_exist);
    $statement_check_roles_exist->execute();
    $statement_check_roles_exist->store_result();
    if ($statement_check_roles_exist->num_rows == 0) {
        $query_insert_roles = "INSERT INTO roles (id, name) VALUES ($admin_role_id, 'admin'), (2, 'user')";
        $statement_inser_roles = $databaseConnection->prepare($query_insert_roles);
        $statement_inser_roles->execute();
    }
}