03.04.2016, 09:15
Your table:
Best is to add default values to columns that have a non-constant value upon creating a row. Columns such as: Admin, VIP, Money, PosX to PosZ all have constant values when you create the player's row.
Your table would look like so:
And your query would then result into:
Код:
CREATE TABLE IF NOT EXISTS `account_data` ( `ID` INT(24) NOT NULL AUTO_INCREMENT, `Password` VARCHAR(129) NOT NULL, `IP` VARCHAR(16) NOT NULL, `Admin` INT(4) NOT NULL, `VIP` INT(2) NOT NULL, `Money` INT(24) NOT NULL, `PosX` FLOAT(24) NOT NULL, `PosY` FLOAT(24) NOT NULL, `PosZ` FLOAT(24) NOT NULL, `PosA` FLOAT(24) NOT NULL, PRIMARY KEY(`ID`) ) ENGINE = InnoDB DEFAULT CHARSET = latin1 AUTO_INCREMENT = 1;
PHP код:
mysql_format(mysql, query, sizeof(query), "INSERT INTO account_data (`Name`, `Password`, `IP`, `Admin`, `VIP`, `Money`, `PosX`, `PosY`, `PosZ`, `PosA`) VALUES ('%e', '%e', '%e', 0, 0, 0, %f, %f, %f, %f)", playername, Account[playerid][Password], playerip, START_X, START_Y, START_Z, START_A);
mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid);
Your table would look like so:
Код:
CREATE TABLE IF NOT EXISTS `account_data` ( `ID` INT(24) NOT NULL AUTO_INCREMENT, `Password` VARCHAR(129) NOT NULL, `IP` VARCHAR(16) NOT NULL, `Admin` INT(4) NOT NULL DEFAULT '0', `VIP` INT(2) NOT NULL DEFAULT '0', `Money` INT(24) NOT NULL DEFAULT '0', `PosX` FLOAT(24) NOT NULL DEFAULT '2492.0830', `PosY` FLOAT(24) NOT NULL DEFAULT '-1665.6895 ', `PosZ` FLOAT(24) NOT NULL DEFAULT '13.3438', `PosA` FLOAT(24) NOT NULL DEFAULT '93.1757', PRIMARY KEY(`ID`) ) ENGINE = InnoDB DEFAULT CHARSET = latin1 AUTO_INCREMENT = 1;
PHP код:
mysql_format(mysql, query, sizeof(query), "INSERT INTO account_data (`Name`, `Password`, `IP`) VALUES ('%e', '%e', '%e')", playername, Account[playerid][Password], playerip);
mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid);