Code: Select all
name=Commander;unitname=ARMCOM;
Moderator: Moderators
Code: Select all
name=Commander;unitname=ARMCOM;
Code: Select all
[CANBUILD]{[ARMCOM]{canbuild1=ARMSOLAR;canbuild2=ARMWIN;}}
Indeed those are workfull news...Maelstrom wrote:Tested it out myself, and you can leave out the newlines. Whitespace and Newlines are completly optional. The following it a valid line:Damn, that makes my life just that little bit harder...Code: Select all
[CANBUILD]{[ARMCOM]{canbuild1=ARMSOLAR;canbuild2=ARMWIN;}}
You don't. You parse the files with some program, like vb, taking as long as you want, and fill a database. Then the php accesses the database.Maelstrom wrote:... I have no idea how to do it in php so that it can parse ~500 files in under 30 seconds. ...
Where you're saying you're filling a database. If you have the databse filled, why would you want to be accessing the mod's structure directly from the files with php?Maelstrom wrote:For those interested in unit pages like AA's [http://www.planetannihilation.com/aa/guide60/index.htm]Unit Guide[/url] I am working on a little php script to do something similar. You can see it here:
http://210.11.113.96/modweb/unit.php?unit=armcom
Its no where near finished yet, but is getting there slowly. It loads all the fbi files in a folder into a database, ...
Not everyone has the ability to run programs on their webserver, as most people rent space from a web host. So im making this all in PHP so everyone can use it. Plus you can run it on linux, unlike VB programs.PauloMorfeo wrote:You don't. You parse the files with some program, like vb, taking as long as you want, and fill a database. Then the php accesses the database.Maelstrom wrote:... I have no idea how to do it in php so that it can parse ~500 files in under 30 seconds. ...
The way this thing will work is like this:PauloMorfeo wrote:Where you're saying you're filling a database. If you have the databse filled, why would you want to be accessing the mod's structure directly from the files with php?
The way im doing it is in no way the most efficient way of doing it. But, with my somewhat limited PHP/MySQL skills (im still learning half the stuff as I go), the only way I could conceviably do it. The structure is like this:PauloMorfeo wrote:Anyway, that's interesting. How is the structure of that database you're using?
I can upload the one i'm using for my program (the most recent version).
Code: Select all
Unit Table:
id - Not used for anyhting, just the key
unitname - The unitname of the unit. ARMCOM for the commander, ect. Read from the FBI files
stat - the name of the property. 'description' for 'description=Commander'
value - the value of the property. 'Commander' for 'description=Commander'
Code: Select all
| id | unitname | stat | value |
+------+----------+------------+---------+
| 1 | ARMCOM | name | Commander |
| 2 | ARMCOM | unitname | ARMCOM |
| 3 | ARMCOM | metalcost | 12345 |
| 4 | ARMCOM | energycost | 234567 |
| 5 | CORCOM | name | Commander |
| 6 | CORCOM | untiname | CORCOM |
Code: Select all
function ParseFile($fileString)
{
$file = array();
//Loop through each character in the file
for ($i++ while $i < strlen($fileString))
{
$chr = character $i in $fileString;
switch ($chr)
{
//Begining of a [section]
case "[":
$sectionName = string between $i and the next "]";
$newFileString = string between $i and the closing '}';
$file[$sectionName] = ParseFile($newFileString);
$i = position of the closing "}"
//Its a setting.
default:
$setting = string betweem $i and the next ";";
$file[bit before the "="] = bit after the "=";
$i = position of the ";"l
}
}
}
Code: Select all
$file = Array
(
Setting1 = Value;
Setting2 = Value;
Section = Array
(
Setting3 = Value;
Setting4 = Value;
)
)
Not the most efficient way but it's close (at least to what i understand as the most efficient way). It's working very similarly to my own database.Maelstrom wrote:...Again, this would not be the most efficient way to do things. But short of altering the table's layout by adding a new column for every new tag, this is the only way I could think of doing it. ...Code: Select all
| id | unitname | stat | value | +------+----------+------------+---------+ | 1 | ARMCOM | name | Commander | | 2 | ARMCOM | unitname | ARMCOM | | 3 | ARMCOM | metalcost | 12345 | | 4 | ARMCOM | energycost | 234567 | | 5 | CORCOM | name | Commander | | 6 | CORCOM | untiname | CORCOM |
Code: Select all
... ARMCOM ...
... ARMCOM ...
... ARMCOM ...
...
Code: Select all
| id | unitname
+------+----------+
| 1 | ARMCOM
| 2 | CORCOM
Code: Select all
| id | idOfUnitToWhichRefers | stat | value |
+--+----+------------+---------+
| 1 | 1 | name | Commander |
| 2 | 1 | unitname | ARMCOM |
| 3 | 1 | metalcost | 12345 |
| 4 | 1 | energycost | 234567 |
| 5 | 1 | name | Commander |
| 6 | 1 | untiname | CORCOM |
Code: Select all
select Table2.* from ComplexJoinSyntax where Table1.Name = 'CORCOM';
Don't forget thatMaelstrom wrote:The following it a valid line:Code: Select all
[CANBUILD]{[ARMCOM]{canbuild1=ARMSOLAR;canbuild2=ARMWIN;}}
Code: Select all
[CANBUILD]{[ARMCOM]{canbuild1=ARMSOLAR; /*comments in the middle!*/ canbuild2=ARMWIN;}}
Arghhzwzsg wrote:...
Don't forget thatis valid too!Code: Select all
[CANBUILD]{[ARMCOM]{canbuild1=ARMSOLAR; /*comments in the middle!*/ canbuild2=ARMWIN;}}
Maelstrom wrote:Eeek. That database your posted is way to complex for me to follow. Ill still try and add that little fix you posted, but im not doing anything like yours, as it is WAY to complex.
Code: Select all
SELECT * FROM Table1 WHERE name= 'armcom';
Code: Select all
SELECT name
FROM first_table
INNER JOIN second_table
ON first_table.keyfield = second_table.foreign_keyfield;
Haa, crap... That's your computer, no? I never seem to be able to catch it online. Or else, he doesn't likes me.Maelstrom wrote:...
http://210.11.113.96/...