Working with auto incriminate
#1

Ok, im creating a business system and i want each business that's created to have its own unique ID so i can tell which business it is and do stuff with it. How exactly can i do this with auto incriminate (mysql) ?
Reply
#2

Create the database and set the part as AUTO_INCREMENT which you want to increment everytime some data is inserted into the fields.

pawn Код:
`id` int(20) NOT NULL AUTO_INCREMENT
Example of creating a database via pawn:
pawn Код:
format(query,sizeof(query),"CREATE TABLE IF NOT EXISTS `Business`(`id` int(20) NOT NULL AUTO_INCREMENT,`owner` varchar(26) DEFAULT NULL,`bname` varchar(40) DEFAULT NULL,`x` float(20) DEFAULT NULL,`y` float(20) DEFAULT NULL,`z` float(20) DEFAULT NULL,");
    strcat(query,"`world` int(10) DEFAULT NULL,`interior` int(10) DEFAULT NULL,`entangle` float(20) DEFAULT NULL,`exangle` float(20) DEFAULT NULL,`locked` int(5) DEFAULT NULL,`price` int(30) DEFAULT NULL,`forsale` int(5) DEFAULT NULL,`cash` int(15) DEFAULT NULL,");
    strcat(query,"`stock` int(10) DEFAULT NULL,`time` int(20) DEFAULT NULL,PRIMARY KEY (`id`))");
    mysql_query(query);
Now on INSERT INTO part you do not need to insert in 'id' field with this type of code.
Reply
#3

Oh ok i thought it would be more complex than that, so each time i enter a form of data it automatically updates that's great news.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)