Thanks for all the replies.
After testing your suggestion, no, successful deduction yet…
And yes, I’m trying chain this function onto the end of the buy-video.php file.
Earlier in that file it shows this:
.
....... etc.
// add data to table
$insert_buy = $db->insert('videos_transactions', [
'user_id' => $video->user_id,//seller
'paid_id' => $user_id,//buyer
'video_id' => $video_id,
'amount' => (string)$video_cost_new,
'admin_com' => $site_add_amount,
'time' => $time_start,
'type' => buy,
'session_key' => $_SESSION['session_key']
]);
// count successful inserted records
if ($insert_buy) {
$inserted_records++;
}
//update the 'balance' of the user who uploaded the video
// get the user's record
$up_user_start = $db->where('id', $video->user_id)->getOne(T_USERS);
// add to the balance
$uploader_account = $up_user_start->balance+$up_amount;
// update the record
$db->where('id', $video->user_id);
$update_balance = $db->update(T_USERS, [
'balance' => number_format($uploader_account, 1, '.', ''),
]);
// reflect the user 50% of the up_amount to show actual money amount
$money_amount = $up_amount *0.50;
//update the 'money' of the user who uploaded the video
// get the user's record
$money_user_start = $db->where('id', $video->user_id)->getOne(T_USERS);
// add to the money
$uploader_account = $money_user_start->money+$money_amount;
// update the record
$db->where('id', $video->user_id);
$update_money = $db->update(T_USERS, [
'money' => number_format($uploader_account, 2),
]);
In this code there is a buyer/user and a seller/uploader.
In the db ‘users’ table there is a ‘balance’ column and a ‘wallet’ column.
I’m trying to add money to the user/uploader (not user/buyer) wallet (not balance). So, based on that, would this still be correct, as show in #5:
$userswallet = $user->wallet;
#5 may be correct possibly up until the UPDATE.
Based on the additional code I’ve provided, can you make another suggestion?
I look forward to your comments. Thanks again