[Tutorial] MySQL plugin ORM usage tutorial
#21

Quote:
Originally Posted by Aliassassin123456
View Post
Thanks for answer so there isn't any reason to replace cache's with ORM
Sure there is. ORM-code is way easier to maintain. With the normal cache-stuff, you'd have to edit the code in several places in your script if you wan't to add a new variable and you also would need to edit some queries. With the ORM-system, all you need to do is to add one line.
Reply
#22

Nice!

I like the news.
Reply
#23

line:
pawn Code:
orm_addvar_string(pInfo[playerid][ORM_ID],pInfo[playerid][Name],"Name");
Gives me this error:
pawn Code:
error 017: undefined symbol "orm_addvar_string"
I copy pasted the name of the function from the include...I just do not get it...Functions like "orm_addvar_int" are working great.

For now, i'm using orm_addvar instead.
Reply
#24

Quote:
Originally Posted by dusk
View Post
line:
pawn Code:
orm_addvar_string(pInfo[playerid][ORM_ID],pInfo[playerid][Name],"Name");
Gives me this error:
pawn Code:
error 017: undefined symbol "orm_addvar_string"
I copy pasted the name of the function from the include...I just do not get it...Functions like "orm_addvar_int" are working great.

For now, i'm using orm_addvar instead.
Correct usage:
Code:
native orm_addvar_string(ORM:id, &var, var_maxlen, varname[]);
you used it like:
Code:
native orm_addvar_string(ORM:id, &var, varname[]);
Reply
#25

Quote:
Originally Posted by IstuntmanI
View Post
Correct usage:
Code:
native orm_addvar_string(ORM:id, &var, var_maxlen, varname[]);
you used it like:
Code:
native orm_addvar_string(ORM:id, &var, varname[]);
Why didn't it give me "number of arguments does not match the definition"....

Anyway, thanks for the help.

Now i can say: great job on the plugin
Reply
#26

Quote:
Originally Posted by dusk
View Post
Why didn't it give me "number of arguments does not match the definition"....
Because it is actually a define:
pawn Code:
#define orm_addvar_string(%0,%1,%2,%3) orm_addvar(%0,%1,DATATYPE_STRING,%2,%3)
and if you don't "complete" the definition perfectly, it will give "undefined symbol" error.
Reply
#27

I can't get how it gets the player's data, so can I have an example how to save the player health and IP and load the health after he logs.
Reply
#28

Quote:
Originally Posted by x96664
View Post
I can't get how it gets the player's data, so can I have an example how to save the player health and IP and load the health after he logs.
There is already such an example in this tutorial here, what is the problem with that example? You better read the tutorial again carefuller.
Reply
#29

Quote:
Originally Posted by maddinat0r
View Post
There is already such an example in this tutorial here, what is the problem with that example? You better read the tutorial again carefuller.
I read it, and couldn't find it, so could you quote it for me ?
Reply
#30

Of course you do !
Reply
#31

Quote:
Originally Posted by fr1run
View Post
Do I need to make SQL Inject protection for ORM?
Quote:
Originally Posted by S4t3K
View Post
Of course you do !
Wrong. The ORM system automatically escapes every string variable.
Reply
#32

I'm loving the ORM support! Development has become really fast.
Reply
#33

Hello! I'd like to use ORM, but I have few concerns.

1. How to handle fields like DATETIME?
2. Does orm_destroy also reset ORM associated variables (like orm_delete does) or do I have to do it manually?
Reply
#34

Quote:
Originally Posted by Pupak
View Post
Hello! I'd like to use ORM, but I have few concerns.

1. How to handle fields like DATETIME?
2. Does orm_destroy also reset ORM associated variables (like orm_delete does) or do I have to do it manually?
1. Just like you would handle them with the standard cache system: as a string.
2. No, it doesn't reset the variables like orm_delete, but that would be a nice addition in R40.
Reply
#35

Quote:
Originally Posted by maddinat0r
View Post
1. Just like you would handle them with the standard cache system: as a string.
2. No, it doesn't reset the variables like orm_delete, but that would be a nice addition in R40.
Sorry, I didn't explain exactly what I need. I have table called "bans" and it contains field like "DateBanned" which is a DATETIME field and "Duration" which is INT field (ban duration in seconds). There is my problem, with standard cache system I was able to fire this query:

pawn Code:
SELECT UNIX_TIMESTAP(`DateBanned`) + `Duration` FROM `bans` WHERE ...
MySQL server would automatically convert DATETIME field to UNIX timestamp and add ban duration to it, then I could simply compare it with gettime() which is an UNIX timestamp too and see is player allowed to be on the server or is he still banned.

I didn't test this with ORM, but I guess if I do:
pawn Code:
new timestamp;

new ORM:ormid = orm_create("bans");
orm_addvar_int(ormid, timestamp, "UNIX_TIMESTAMP(`DateBanned`)");
It would produce query like this:
pawn Code:
SELECT `UNIX_TIMESTAMP(`DateBanned`)` ...
Which would result in query error. Am I wrong? Is there any other way to do it with ORM or should I stick to standard cache system? It's not a problem, I can mix ORM and cache and use it for different parts of my code, but if it all could be just ORM it would be great.
Reply
#36

This is an amazing tutorial and really help individuals like myself who have very few knowledge to learn how to use the Mysql plugin better. You're Tutorial Andre been following your Mysql Tutorials and all have helped in the passed
Reply
#37

deleted
Reply
#38

Sorry for late bump.

I have question:

I'm using this system, and around 350 players server starts lagging, and somehow people are loosing stats, i mean their variables are not being saved(lost), while below 300 players everything works fine. Sometimes, password of players are not saved.

And i'm using only orm for account saving , for vehicles/stuff im using Y_INI.

So, my question is, if i transfer whole houses/vehicles/stuff to ORM, and remove Y_INI, what are the chances of loosing variables, or would lag be increased?

Also, what's faster, if i use tquery ( UPDATE variable etc ), or ORM system?
Reply
#39

Quote:
Originally Posted by DeitY
View Post
Sorry for late bump.

I have question:

I'm using this system, and around 350 players server starts lagging, and somehow people are loosing stats, i mean their variables are not being saved(lost), while below 300 players everything works fine. Sometimes, password of players are not saved.

And i'm using only orm for account saving , for vehicles/stuff im using Y_INI.

So, my question is, if i transfer whole houses/vehicles/stuff to ORM, and remove Y_INI, what are the chances of loosing variables, or would lag be increased?

Also, what's faster, if i use tquery ( UPDATE variable etc ), or ORM system?
The best thing for you and such big server is to use cache function's ( https://sampwiki.blast.hk/wiki/MySQL/R33#Cache_functions). And about 300+ player's stat's not getting saved, when this bug occur (when you gmx ? when they normaly exit ? ...)
Reply
#40

Quote:
Originally Posted by m0k1
View Post
The best thing for you and such big server is to use cache function's ( https://sampwiki.blast.hk/wiki/MySQL/R33#Cache_functions). And about 300+ player's stat's not getting saved, when this bug occur (when you gmx ? when they normaly exit ? ...)
Uhm ORM doesnt use any query, plugin does that job itself, neither cache functions, so this won't help me m0k1. Occurs mostly at ddos attacks/high number of players.

So your post still won't help me, anyone else?
Reply


Forum Jump:


Users browsing this thread: 8 Guest(s)