PDA

View Full Version : ORM


speed258
27/01/2014, 02:40 PM
Hi guys totally noob on ORM systems and i have no clue how to make data retrieving from old table, before retrieving old table i create new one and from old i want to get data and put into new one so any ideas? Thanks.

speed258
27/01/2014, 02:56 PM
UP>>>

Misiur
27/01/2014, 02:59 PM
First, read carefully ORM tutorial (forum.sa-mp.com/showthread.php?t=461766).

Now, for the workflow:
1. Create key, and select data from first table
2. Run threaded query creating new table
3. In callback create key for new table
4. Copy contents from first array into second array
5. Use orm_save on new table

speed258
27/01/2014, 03:24 PM
stock LoadServersConfig()
{
new Year, Month, Day, date[20], date1[20], Hour, Minute, Second;
getdate(Year, Month, Day);
gettime(Hour, Minute, Second);
format(date, sizeof(date), "%d-%02d-%02d",Year,Month,Day);
format(date1, sizeof(date), "%d:%d:%d",Hour,Minute,Second);
strins(server[ond], date, 0);
strins(server[ont], date1, 0);
server[ORMID] = orm_create("server", dbhandle);
orm_addvar_int(server[ORMID], server[session], "session");
orm_addvar_string(server[ORMID], server[ond], 50, "OnD");
orm_addvar_string(server[ORMID], server[ont], 50, "OnT");
orm_addvar_int(server[ORMID], server[ownedb], "ownedb");
orm_addvar_int(server[ORMID], server[maxown], "Cars");
orm_setkey(server[ORMID], "session");

orm_select(server[ORMID], "LoadID", "i", server[session]-1);
//orm_insert(server[ORMID], "LoadID", "", "");
}

forward LoadID(i);
public LoadID(i)
{
orm_addvar_int(server[ORMID], server[ownedb], "ownedb"); // i thinking here to retrieve old data info from old table which session is lover by -1
orm_addvar_int(server[ORMID], server[maxown], "Cars");
orm_insert(server[ORMID], "LoadServersOldInfo", "");
return 1;
}

forward LoadServersOldInfo();
public LoadServersOldInfo()
{
orm_update(server[ORMID]);
return 1;
} So where is problem session retrieves but ownedb and maxown wont.

speed258
27/01/2014, 03:30 PM
stock LoadServersConfig()
{
new Year, Month, Day, date[20], date1[20], Hour, Minute, Second;
getdate(Year, Month, Day);
gettime(Hour, Minute, Second);
format(date, sizeof(date), "%d-%02d-%02d",Year,Month,Day);
format(date1, sizeof(date), "%d:%d:%d",Hour,Minute,Second);
strins(server[ond], date, 0);
strins(server[ont], date1, 0);
server[ORMID] = orm_create("server", dbhandle);
orm_addvar_int(server[ORMID], server[session], "session");
orm_addvar_string(server[ORMID], server[ond], 50, "OnD");
orm_addvar_string(server[ORMID], server[ont], 50, "OnT");
orm_addvar_int(server[ORMID], server[ownedb], "ownedb");
orm_addvar_int(server[ORMID], server[maxown], "Cars");
orm_setkey(server[ORMID], "session");

orm_select(server[ORMID], "LoadID", "i", server[session]-1);
//orm_insert(server[ORMID], "LoadID", "", "");
}

forward LoadID(i);
public LoadID(i)
{
orm_addvar_int(server[ORMID], server[ownedb], "ownedb"); // i thinking here to retrieve old data info from old table which session is lover by -1
orm_addvar_int(server[ORMID], server[maxown], "Cars");
orm_insert(server[ORMID], "LoadServersOldInfo", "");
return 1;
}

forward LoadServersOldInfo();
public LoadServersOldInfo()
{
//also i here put printf with maxown and prints me 0 but in old table is 9
orm_update(server[ORMID]);
return 1;
} So where is problem session retrieves but ownedb and maxown wont. Sorry for Double post mouse stuck on it

speed258
27/01/2014, 04:02 PM
up...