SA-MP Forums Archive
Who better? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Who better? (/showthread.php?tid=373127)



Who better? - ScriptWriter - 29.08.2012

Hi, scripters. I need you advice again (If anyone remember me ), who better mysql_get_field or cache_get_row for RP server? I don't need dumbs answer. I need only advice.
- ScriptWriter


Re: Who better? - HuSs3n - 29.08.2012

cache_get_row is alot better and easier

thats a QUOTE from caching tutorial

Quote:
Originally Posted by AndreT
Посмотреть сообщение
Benefits of using the cache

* It is faster! Using cache functions instead of mysql_fetch_row is notably faster. For JernejL, loading 1300 vehicles from the database went from 6 seconds to 60 milliseconds (source) and from my personal experience, I can tell that loading 500 houses from a database is now at least 10-20 times faster (source). Here are some more results.
* It does not require the coder to store/free the query result! There's no need to call mysql_store_result() to store the result or mysql_free_result() to free the result after done processing it. Specifically the result freeing has proven itself to be a source of problems, specially for newer scripters.
* It is easier to read/write/modify! (depending on the programmer's own preference)
To continue with, parsing the query result has become simpler compared to several older methods like sscanf.


With mysql_fetch_row, no caching
1. mysql_fetch_row calls took 3065 milliseconds
2. sscanf (parsing) took 27ms in total (500 calls to function)
3. the rest of the house loading code took 129ms (irrelevant)
Total: 3221ms

With caching
1. cache functions (loading and parsing) took 166ms
2. the rest of the house loading code took 108ms (irrelevant)
Total: 274ms

From this, we can tell that using the caching functions is about 12 times faster in such example (with loops and huge rows of data being returned).



Re: Who better? - ScriptWriter - 29.08.2012

Thanks for advice. But now i want ask you.
First: How get AUTO_INCREMENT type field value when use cache_get_row function?
Second: How save string type variable in mysql?


Re: Who better? - ScriptWriter - 29.08.2012

Bump


Re: Who better? - Misiur - 29.08.2012

AUTO_INCREMENT is an attribute, not a field type. It is integer. String - varchar. Text for long texts


Re: Who better? - HuSs3n - 29.08.2012

use mysql_insert_id to get AUTO_INCREMENT value
pawn Код:
mysql_function_query(server,"INSERT INTO .......",true,"GetID","");

forward GetID();
public GetID()
{
      printf("%d",mysql_insert_id(server));
      return 1;
}