In addition to echoing out the query, you would want to check any variables in that part of the code. The construction of the ternary operator line looks odd. Typically I would put the conditions (especially when there are multiple) within parens. Although, that does seem to work in my install. I see that the $upwalle value is being put into quote marks in the query, which is not proper for a numerical value - same with the id value. Also, you are ALWAYS running the query even if you are not intending to change the value. You should only run the query if you are intending to make a change.
Here is some very verbose debugging. I also made some minor tweaks to the code. What are your results when running this:
echo "Get user for id: {$video->user_id}<br>";
$up_user = $db->where('id', $video->user_id)->getOne(T_USERS);
echo "Get wallet amount for user: ";
$uploader_wallet = $up_user->$user->wallet;
echo "{$uploader_wallet}<br>";
echo "Calculate change to wallet: ";
$upwallet = ($sell_video == 0 && $uploader_wallet >= 1) ? .5 : 0;
echo "{$upwallet}<br>";
echo "Check if upwallet value is not zero: ";
if($upwallet > 0)
{
echo "True - run update query<br>";
echo "Construct query: ";
$query = "UPDATE ".T_USERS." SET `wallet` = (`wallet` - {$upwallet}) WHERE `id` = {$video->user_id}";
echo "{$query}<br>";
echo "Run query: ";
$db->rawQuery($query);
echo "Complete";
}
else
{
echo "False - do not run update query<br>";
}