How to subtract a value
This is a very noobish question, but how do you properly subtract a value from all rows in a table? I've tried this:
PHP Code:
PHP Code:
|
You'll have to get the current value(s) first and then subtract. The update function just sets the variable to whatever you tell it to, but cannot math at it.
This would be an example of how to reduce the current user's money: PHP Code:
PHP Code:
PHP Code:
|
You can also create your own database function to add that functionality from mysql to Mysidia, so you avoid having two transactions, select and then update
class_database.php PHP Code:
PHP Code:
It depends on your taste. I've been adding some things from mysql to mysidia's database class in the last few days, that's why I'm giving this option xD |
Yeah ... that's great ! Thank you for sharing this:smile:
|
Ohh ... I have a request.
I would like to install a second requirement. So I would like to have : mood - 2, but only if "is frozen" no. How is this going ? thanks in advance |
It should be:
PHP Code:
PHP Code:
|
Ah ... great !
it works, but with ' isfrozen = 'no' thank you, Dinocanid :jay: |
All times are GMT -5. The time now is 07:52 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.