Banks in mysql [+REP]
#1

Hello everyone, I've thought about making a bank for the server in mysql.
So, all what will be saved is, Balance (the amount of money), and the bank manager.
Of course, I have to make a new table, but how? like users table or what?
Reply
#2

Use the table with user accounts. Create columns with names: money, card(if necessary), etc.
Reply
#3

Well, balance and manager are not enough you will need something like name so you can make a query to get player's money or if player is manager, in case you want to create a table go to your phpmyadmin site, which one is provided from your host and click on your database then in bottom you will find a box named Create Table, create a table and put your columns there
Reply
#4

Код:
Query the following: CREATE TABLE IF NOT EXISTS `bank` (`Balance` INTEGER DEFAULT 0 NOT NULL, `Manager` VARCHAR(24), `ID` INTEGER NOT NULL PRIMARY KEY)
Create a bank enumerator for storing all of the SQL bank data in to their correct variables (and setting the bank enumerator values to their correct SQL variable).

Enumerator Example:

Код:
enum BankData
{
bID,
bBalance,
bManager[24],
};
new bData[MAX_BANK][BankData];
Updating the SQL table (example):

Код:
"UPDATE `bank` SET `Balance` = %d, `Manager` = '%s' WHERE `ID` = %d", bData[bankid][bBalance], bData[bankid][bManager], bData[bankid][bID]
Loading the bank table's data from the SQL server and storing it in to the BankData enumerator:

Код:
"SELECT * FROM `bank` WHERE `ID` = %d", bData[bankid]);

             new rows, fields;

	cache_get_data(rows, fields, serverhandle);

	for (new i = 0; i < rows; i ++) 
	{
                   bData[bankid][bID] = cache_get_field_int(i, "ID")
                   bData[bankid][bBalance] = cache_get_field_int(i, "Balance")
                   cache_get_field_content(i, "Manager", bData[bankid][bManager], serverhandle, 24);
              }
You can figure the rest out through SQL tutorials. You also have to create your own callbacks and sort the above scripting in to the correct callbacks.
Reply
#5

Quote:
Originally Posted by IzadorO
Посмотреть сообщение
Код:
Query the following: CREATE TABLE IF NOT EXISTS `bank` (`Balance` INTEGER DEFAULT 0 NOT NULL, `Manager` VARCHAR(24), `ID` INTEGER NOT NULL PRIMARY KEY)
Create a bank enumerator for storing all of the SQL bank data in to their correct variables (and setting the bank enumerator values to their correct SQL variable).

Enumerator Example:

Код:
enum BankData
{
bID,
bBalance,
bManager[24],
};
new bData[MAX_BANK][BankData];
Updating the SQL table (example):

Код:
"UPDATE `bank` SET `Balance` = %d, `Manager` = '%s' WHERE `ID` = %d", bData[bankid][bBalance], bData[bankid][bManager], bData[bankid][bID]
Loading the bank table's data from the SQL server and storing it in to the BankData enumerator:

Код:
"SELECT * FROM `bank` WHERE `ID` = %d", bData[bankid]);

             new rows, fields;

	cache_get_data(rows, fields, serverhandle);

	for (new i = 0; i < rows; i ++) 
	{
                   bData[bankid][bID] = cache_get_field_int(i, "ID")
                   bData[bankid][bBalance] = cache_get_field_int(i, "Balance")
                   cache_get_field_content(i, "Manager", bData[bankid][bManager], serverhandle, 24);
              }
You can figure the rest out through SQL tutorials. You also have to create your own callbacks and sort the above scripting in to the correct callbacks.
Thank you very much!
That's a complete answer.
+1337REP
Reply
#6

Sorry for double-post.
But, where to put that code "CREATE TABLE IF NOT .."?
And the ID of bank auto increases?

And when I compile it, it says: "error 017: undefined symbol "bankid"
How to define the "bankid" ?
Reply
#7

Sorry for Bump
But my question is: How to define the "bankid"? When I do "bData[bankid][bBalance]" it says: "Undefined symbol "bankid", I mean how can I be able to do bData[bankid][bBalance] ?
ANSWER ASAP PLEASE!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)