The WordPress way to do this would be to use the WPDB class to do your database queries. As an example...
$query = "SELECT ID FROM my_table WHERE downloaded = 0";
$wpdb->get_results ($query);
$wpdb->update ('my_table', array (
'downloaded' => 1,
'download_user' => 53,
'download_time' => date ('Y-m-d H:i:s')
));
There's a whole lot more information and examples on the codex page, so have a look through it and I'm sure you'll find that it's what you're looking for.