06.08.2016, 00:41
(
Последний раз редактировалось AndySedeyn; 06.08.2016 в 01:26.
)
Quote:
Alright, any clue how I am supposed to deal with the job ids?
|
As for your question, the database ID is only used in queries. Session ID and Database ID is something to be kept apart because of the fact that you use an array to access the enum and arrays start counting at 0, unlike your A_I field. I personally prefer keeping the 0-start instead of adding 1 to every index.
To achieve that, I keep an extra boolean enumerator usually called 'bool: xxExists'. Fill in the 'xx' yourself or remove it. This variable is not saved.
Loading:
PHP код:
for(new i = 0, j = cache_get_row_count(); i < MAX_JOBS && i < j; i++) {
jobData[i][Exists] = true;
// Load other data
}
PHP код:
for(new i = 0; i < MAX_JOBS; i++) if(!jobData[i][Exists]) {
jobData[i][Exists] = true;
// Save other data
}
There are countless ways of achieving the same thing, but I do it like this. I'm open to hear from others on how to do it differently.