SA-MP Forums Archive
ORM - 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: ORM (/showthread.php?tid=490647)



ORM - speed258 - 27.01.2014

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.


Re: ORM - speed258 - 27.01.2014

UP>>>


Re: ORM - Misiur - 27.01.2014

First, read carefully ORM tutorial.

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


Re: ORM - speed258 - 27.01.2014

Код:
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.


Re: ORM - speed258 - 27.01.2014

Код:
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


Re: ORM - speed258 - 27.01.2014

up...