Jump to content

Archived

This topic is now archived and is closed to further replies.

Monkuar

Inventory Management Storage

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.

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

×
×
  • 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.