PDA

View Full Version : What is the better way? Array or MYSQL?



Surekin
November 8th, 2008, 09:46 PM
Hey!

The title sounds a bit wrong, but what i mean is:

If i have a database with many different entries and i collect the data into flash via XML what is the better way to sort it out? Is it easier to load different PHP/XML Files for every query i have or is it easier to load the whole database via one xml into an array and make the queries with that array?

by queries i mean f.e. Sort by Id, sort by date, select where id=something

easy to do for me with SQL/PHP, but i dont know (yet) how capable arrays are...
What ways to you use?

Cheers

theCodeBot
November 8th, 2008, 10:20 PM
For the sake of (admittedly complex) organization, my personal preference would be to have flash send/receive to/from a PHP backend that queries the SQL database and returns XML, then I would parse that to an array that you can call sortOn() against and finally loop through the sorted array and display it in your grid.

Surekin
November 8th, 2008, 10:25 PM
For the sake of (admittedly complex) organization, my personal preference would be to have flash send/receive to/from a PHP backend that queries the SQL database and returns XML, then I would parse that to an array that you can call sortOn() against and finally loop through the sorted array and display it in your grid.

ok...but what about if i have more queries than one... and i have a live sort function and and and...my problem is that in my case i'd have to load like 20 different Xml Files to have all queries done...i sure have only 2 php files which convert the queries via variables, but anyway i'd have to load the file like 20 times, so for me it may be easier to loade the whole thing into flash via one BIG Xml and sort it out then...maybe, or not...:-) ?

creatify
November 8th, 2008, 10:55 PM
Have you looked into AMFPHP? AMFPHP will serialize your data from the db, well, granted it does return an array of records, but, via the gateway file you can add as many filter/sort/queries as you'd like and make those calls directly from flash. And it's super fast compared to XML.

theCodeBot
November 9th, 2008, 09:13 AM
ok...but what about if i have more queries than one... and i have a live sort function and and and...my problem is that in my case i'd have to load like 20 different Xml Files to have all queries done...i sure have only 2 php files which convert the queries via variables, but anyway i'd have to load the file like 20 times, so for me it may be easier to loade the whole thing into flash via one BIG Xml and sort it out then...maybe, or not...:-) ?
I'd take Creatify's advice. what I posted was only my personal preference in these dealings... my preference is seldom, if ever, the accepted norm or standard.

scottc
November 9th, 2008, 09:20 AM
you could connect directly to the database with Socket(); and query the database directly.

But i don't recommend it, too much security(holes) involved... also you'll have to setup a "SELECT only" user for the db, policy file... and only a few tables available to the db user.

Surekin
November 9th, 2008, 09:59 AM
Have you looked into AMFPHP? AMFPHP will serialize your data from the db, well, granted it does return an array of records, but, via the gateway file you can add as many filter/sort/queries as you'd like and make those calls directly from flash. And it's super fast compared to XML.

i have looked into it for sure, but i'm experiencing server probs after the installation, and my hoster says it has something to do with the .htaccess files...but this file is empty on my server, so i'm stuck and i left it on the side...

so nobody said till now that arrays are good to query data...so i'll stay with the php/mysql thingy...