PDA

View Full Version : multiple or single data sending ?


Kachoudas
09-06-2004, 06:40 PM
Hello,

For learning reasons, I'm working on a game where I'll be saving on a mysql database datas about around 50 object (x, y, rotation, other stuff including potentially long text - around 12 field by objects).
I'm using loadVars objects, sending them to a PHP page that put them in mysql. It's a turn by turn game, so I don't need to save them very often.


I was wondering : should I send all the datas at once (1 time 50*12 fields), or should I send them object by object (50 time 12 fields) :confused:

does it make any difference ? In term of speed, stability, easyness ? the second version seems easier to write. What if (VERY theorical question ;) ) a few dozens, or a few hundreds players, use the game at the same time?

And the reversed question : can I also use lots of multiple calls to small PHP to read the database whenever I need it, or should I better load everything at once ?

Thanks for your help !

Jerome

hangalot
09-07-2004, 01:18 AM
i big call will be more optimal since u can then insert everything in 1 db session, vs open the connection to the db, and writting ur data then closing the db connecton.
same applies for reverse but since it is to the client u might want to think about this, it really depends on the size of the indiv chunks of data.

look into remoting (there are free php 1nes availible) that makes db connectivity much faster and more lightweight.

petefs
09-07-2004, 06:30 AM
What hangalot said -- for something like this you'll want to use at the very minimum a php remoting class such as AMFPHP or PHPObject. You'll make a persistent connection to the db and complex structures such as objects and arrays can be passed natively and parsed into a format that can be stored by the db.

If the game plans on getting more traffic and requires lower latency/overhead, you'll want to look into XMLSocket communication most likely.

Kachoudas
09-07-2004, 06:09 PM
Thanks guys, I think I get the idea. A little abstract to me yet ;) but I 'll look for PHPObjects and for persistents connections.
I guess "free php 1nes" means stuff like PHPObject ?

thanks
Jerome