PDA

View Full Version : [EasyDB]Creating Issue


Yaa
03/12/2016, 03:22 PM
Hello !

Why it's not creating the table :/

There my settings :

#define SQL_DATABASE "test" // your database name
#define SQL_SERVER "localhost" // your mysql host/server address
#define SQL_USERNAME "root" // your mysql administration access user
#define SQL_PASSWORD "" // password for the user

#include <easyDB>


and my creating Section :

DB_INIT();
print("DB Loading.....");
DB_CREATE_TABLE("accounts");
DB_StringField("name");
DB_StringField("salt");
DB_StringField("password");
DB_StringField("ip");
DB_IntField("kills");
DB_IntField("deaths");
DB_IntField("cash");
DB_IntField("admin");
DB_IntField("kicks");
DB_IntField("bans");
DB_IntField("id");
DB_PrimaryKey("id");
DB_CLOSE();

Any Help Please ?

Thanks in advence !

Gammix
03/12/2016, 04:39 PM
I didn't added the support of creating a database with DB_INIT, you have to make the database yourself. Well i guess i'll add that in next update of easydb.

EDIT: You cannot run a query since your require a database name while connecting to mysql through mysql_connect.

Yaa
03/12/2016, 04:49 PM
I didn't added the support of creating a database with DB_INIT, you have to make the database yourself. Well i guess i'll add that in next update of easydb.

what that means ? *-----> DB_CREATE_TABLE("accounts");

iLearner
03/12/2016, 04:53 PM
"Table" not "DB", mister SA-MP Lead Scripter.

Yaa
03/12/2016, 04:55 PM
LOL I have a mistake !

it's don't create table not db :3

Gammix
03/12/2016, 04:58 PM
LOL I have a mistake !

it's don't create table not db :3

You only need to create the database. DB_CREATE_TABLE does the table work.

Yaa
03/12/2016, 05:02 PM
You only need to create the database. DB_CREATE_TABLE does the table work.

That why im posting here DB_CREATE_TABLE Not working :/

Notice: Im Using MySQL R41

SickAttack
03/12/2016, 05:55 PM
Just remove that include and do it normally. From the looks of it, it executes multiple ALTER statements, which is just rediculous.

Gammix
03/12/2016, 06:08 PM
Just remove that include and do it normally. From the looks of it, it executes multiple ALTER statements, which is just rediculous.

If the table isn't created, CREATE TABLE is executed only once taking care of every field mentioned in the DBIndex; Just like normal SQL query.

If the table already exist, ALTER TABLE is the only way.

I know its better to write queries and feel free to switch anytime. The major benefit you get from this is that you can shift to SQLite or MySQL anytime, you'll be able to port all the rows from MySQL to SQlite or vise versa.

@Yaa: I'll take a look into the issue and let you know.

Yaa
03/12/2016, 06:38 PM
okey thank you anyway