Jump to content

Inventory Management Storage


Monkuar

Recommended Posts

Before reading: I already have a system in place for inventory management. I use it with a rpg_items database with a field called 'item_slot', etc and it works wonderfully.

 

My issue is. I think it would be intuitive if I were to store a basic 20 slot 0 iteration in a field under the users table for each character. So I can just check against that, instead of querying the whole rpg_user_items table, (which will have thousands, hundreds of thousands of users items) to just check if a user's inventory is full, that is not intuitive. I'd rather just check if a field name has no open 0's instead with php. (This ofcourse will be updated dynamically upon a user moving their items to different slots).

 

 

Let's say I have this array, and it's stored in a field called userinventory in the users table:

 

0,0,0,0,0
0,0,0,0,0
0,0,0,0,0
0,0,0,0,0
This is pretty easy to read. there is 20 slots, 5 on reach row. That's 20 inventory slots a user has access to.

 

This is supposed to represent something like this:

 

4a7aaf8e33844ee325f43ccf8c6b2360.png

 

I can store this in the MYSQL field as 'userinventory'.

 

Now, how do I go about dynamically each specific 0 (ZERO) in this Block? I'm going to call this a block.

 

I will need to label it accordingly.

 

Paint time.

 

Here u go

 

22285ded29452685d295a0d983608640.png

 

How do I use PHP to dynamically update a block like this based upon user input? (A 1, A 2, A3, B2, B1, etc)

 

To check if a user's inventory is full would be easy. I can just explode them by ',' and use count to see if it's greater than 20. My problem is about updating each individual block to represent a users inventory.

 

So, if there is a 1 there, an item would be there. That's all I'm trying to do.

 

I could ofcourse, create what 20 (5x4) if functions to place them at each individual block, but that wouldn't be intuitive and be extremely confusing.

Edited by Monkuar
Link to comment
Share on other sites

I'm sure that this:

 

store a basic 20 slot 0 iteration

 

makes a ton of sense to you. Not to me.

 

My one comment on something that I do understand - you have a system that stores multiple pieces of the same discrete data item into one field? Well if it works it works, but it is certainly not a RDBMS. Every time you read something you have to break it down into useable values and when you store it you have to reverse that process. Horrible design.

Link to comment
Share on other sites

I'm sure that this:

 

store a basic 20 slot 0 iteration

 

makes a ton of sense to you. Not to me.

 

My one comment on something that I do understand - you have a system that stores multiple pieces of the same discrete data item into one field? Well if it works it works, but it is certainly not a RDBMS. Every time you read something you have to break it down into useable values and when you store it you have to reverse that process. Horrible design.

Yeah, but that's why I already store the users items in a table and have them for each row. So I don't have to do that.

 

But I'm trying to store the users inventory into a field like this so I don't have to query the rpg_user_items database everytime just to check if a users inventory is full, you know? Hope this helps

Edited by Monkuar
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.