php/mysql help

I am trying to find a way to massively descrease the number of mysql queries i performing.

I currently have an inventory table which is wrote to each time an item is found, it also has to check if the player already has that item, and adds the quantity to that record or if not exists then creates a new record.

What I want to do instead is store a string within my LSL script and only update the database in bulk.
I will remove the inventory table and store all the inventory data in a text field in the player table.

I receive a string of itemID’s and quantities from the LSL script:
itemID,Quantity,itemID,Quantity,itemID,Quantity,itemID,Quantity

I dont know how many there will be each time…

Then i will query the DB to get the existing string of inventory.

I then want to merge the 2 strings where the inventory already exists and add any new ones to the end.

So basically:

$LSLstring = 1,1,2,1,3,1,5,1
$stringFromDB = 1,10,2,1

$newString = 1,11,2,2,3,1,5,1

I hope that makes sense!

Well, first, why use strings for numeric work? Why not use an array, so your LSL would have a list of itemID=>quantity … Then, you could just create a query that would update the inventory with these numbers.

But, that is off-topic as you didn’t actually ask us a question…

What part of this code that you didn’t show is giving you problems. Help us help you…

Sponsor our Newsletter | Privacy Policy | Terms of Service