Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Future Improvements (https://forums.graalonline.com/forums/forumdisplay.php?f=10)
-   -   Database objects (https://forums.graalonline.com/forums/showthread.php?t=75975)

DustyPorViva 07-31-2007 06:58 AM

Database objects
 
I don't know if this, or anything akin to this, is already possible... so excuse this post if it is. I propose a new type of object, database objects. These would be much like a spreadsheet, where you create a database, and can add/remove rows and columns.

NPC Code:

items = new TstaticDB(); // sorry, I dunno how you initialize new variables

items.createrow("Image"); // Creates a row named 'Image'
items.createrow("Weaponname"); // Creates a row 'Weaponname'
items.createrow("Weight"); // Creates a row 'Weight'
items.addcolumn("Bow"["Image"="wbowi1.png","Weaponname"="-Bow","Weight"=6]]); // Adds a named Bow, specifying the rows for the Image,Weaponname, and Weight

items.deleterow("Weaponname") // Removes the row 'Weaponname'



and to access the database object:

NPC Code:

temp.test=items.column("Bow"); // would return {wbowi1.png,-Bow,6}
temp.test=items.row("Image"["Bow"]); // would return wbowi1.png
temp.test=items.row("Image"); // would return an array of all items in the Image row



I was posting this as I went, so things might be disorganized, and it might not be the best design of commands and such, but I think you get the idea. If anyone has suggestions on what to add to this, go ahead.

theHAWKER 08-01-2007 02:02 AM

thats a good idea...

Codein 08-01-2007 02:11 AM

Good idea but I suggest using columns for fields and rows for entries.

Maniaman 08-01-2007 02:12 AM

MySQL support would be really nice.

JkWhoSaysNi 08-01-2007 02:47 AM

Whats the point?

You can do:

items.row1.bow = "whatever";
items.row1.somethingelse = "foo";
items.row2.bow = "...";
etc.

This is LESS limited than your model because it's easier to set up and has the potential of different numbers of fields for each row.

The only thing needed in a database object is a good querying method. If XPath were implemented we could have XML "databases". (Inefficient in larger systems, but for graal sized systems with probably less than 1000 records it'd be ok).

DustyPorViva 08-01-2007 02:51 AM

Ya... except you have to create a different variable for every bit of information. This would contain all the information into one object.

xXziroXx 08-01-2007 12:05 PM

PHP Code:

items = new TStaticVar();
temp.rows 3;
for (
0temp.rows++) items.("row" i) = new TStaticVar();
items.row1.lawl "foo";
items.row3.pie "gewd";

// Try this afterwards Dusty:
echo(items.getDynamicVarNames());
for (
temp.var: items.getDynamicVarNames()) echo(temp.var @ ":" SPC items.(temp.var).getDynamicVarNames()); 


DustyPorViva 08-01-2007 12:33 PM

Well, the whole reason for this idea is to have one object to hold a lot of information in an organized way, and to have it easily accessible.
Instead of having a variable for every item(which gets annoying to go through), it would all be there in one easy-to-access database.
I don't really understand the objection just because there are alternatives. There have been a lot of additions to Graal made just to make things easier.

xXziroXx 08-01-2007 02:17 PM

I'm only using ONE object - a TStaticVar.

JkWhoSaysNi 08-01-2007 08:29 PM

Quote:

Originally Posted by DustyPorViva (Post 1336204)
Well, the whole reason for this idea is to have one object to hold a lot of information in an organized way, and to have it easily accessible.
Instead of having a variable for every item(which gets annoying to go through), it would all be there in one easy-to-access database.
I don't really understand the objection just because there are alternatives. There have been a lot of additions to Graal made just to make things easier.

In my example the items object holds everything.

Inverness 08-01-2007 10:57 PM

I designed a form database system earlier. Forms being arrays, first variable being the type so you can identify the other variables. Forms are saved automatically on change and send to clients that have them downloaded on change. This system is completely based off the one used for data in Morrowind and Oblivion. I however, decided not to use it for Val since I don't know how Graal would handle it if it gets large.

DustyPorViva 08-01-2007 11:00 PM

Well, I know something similar CAN be done, but that's besides the point. I think something like this would make a lot of things really simple. So why not?

killerogue 08-01-2007 11:04 PM

Has everyone ignored the fact that databases themselves are objects? XD

Rapidwolve 08-02-2007 01:08 AM

Didn't somebody make a really complex GSSQL system? It was like a SQL database but made in GS2.

Ah found it:
http://forums.graalonline.com/forums...ighlight=GSSQL

Admins 08-09-2007 01:45 PM

There is already support for MySQL in Graal, it is not enabled for most servers though. Also the creation of tables, indices etc. cannot be done by Graal script directly.


All times are GMT +2. The time now is 02:41 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.