Author Topic: Storing objects under MySQL  (Read 390 times)

Legacy_Kato -

  • Hero Member
  • *****
  • Posts: 747
  • Karma: +0/-0
Storing objects under MySQL
« on: January 07, 2012, 05:16:01 pm »


               Hi,

I'm having some problems storing objects(more precisely a store) to a MySQL table using REPLACE INTO. I've had some similar problems in the past when using INSERT...ON DUPLICATE KEY UPDATE, wich were sloved thanks to Virusman who informed me that the latter cannot work with objects(yet it works for any other data type). Does anyone know if it's also the case with REPLACE INTO?

Thank you!


Kato 
               
               

               


                     Modifié par Kato_Yang, 07 janvier 2012 - 05:31 .
                     
                  


            

Legacy_Kato -

  • Hero Member
  • *****
  • Posts: 747
  • Karma: +0/-0
Storing objects under MySQL
« Reply #1 on: January 08, 2012, 04:11:14 pm »


               Ha, I've just found the answer: StoreCampaignObject() only stores items and creatures, and it does not seem possible to store objects in a more "direct" fashion, StoreCampaignObject() seems to be the only alternative. It explains why most storage systems use an invisible creature as the "container". The NPC's inventory is filled, then the NPC itself is stored in the DB.

So it leaves two solutions: Storing the items as a whole(in a tinyblob type column), or storing the items ref + stack + charges and re-create them at retrieval time. I wonder wich of these two possibilities will create the less lag, though. Any idea?

Thank you!


Kato
               
               

               


                     Modifié par Kato_Yang, 08 janvier 2012 - 04:17 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Storing objects under MySQL
« Reply #2 on: January 08, 2012, 04:24:00 pm »


               The reasom most people do not store Items by ResRef is that It does not allow for any items that do not comform to the BluePrint.  

If someone in your world goes to a crafter and gets a D6 fire damage added to there sonic sword and then gives it a new name, when it comes back out of the storage system, stored by ResRef, it is going to be just a sonic sword again.
               
               

               
            

Legacy_Kato -

  • Hero Member
  • *****
  • Posts: 747
  • Karma: +0/-0
Storing objects under MySQL
« Reply #3 on: January 08, 2012, 04:27:31 pm »


               Oh! I did ignore this, thank you Lightfoot. It certainly answers my last question then, I'll store items as a whole.


Kato