Jump to content

quick question


Monkuar

Recommended Posts

Does storing multiple values in 1 database field with a varchar let's say set at 150, all separated by

"|'s" so I don't have to create a field name for each one is it better performance wise or no? (storing 6-7 different |'s that will be outputted with a array ofc)

 

?

 

 

Link to comment
Share on other sites

Storing data in a comma separated fashion within a database is generally a bad approach. It makes searching your data for more difficult.

 

this data will not be searched though,  (didn't point that out, my fault)

 

here is a s/s of what the data looks like that is being called

 

This way would be better instead of adding 8 more rows to call each | data right?

 

pk5g.png

 

See, i would have to add like 12 more fields just to get the data I want to pull out, but doing it this way it's alot simpler to me (IMO)

 

These is the board's main stats (it's being called whenever sum1 visit's the board forum index) it should be fine?

 

there both varchar's (100)

Link to comment
Share on other sites

The thing is, you're making this way more complicated than it really needs to be.

 

If you would start putting your variables in arrays, instead of all your variables in one string, you won't need to find all your variables in that string when you need them and you can easily piece them into an output string when you do need to show them.

 

This also means you can easily store each variable into a database via a loop so that the integrity of the data is maintained while storing, retrieving, and updating them.

 

Your database could look like this:

 

[ticket] - [choice 1] - [choice 2] - [choice 3] - [choice 4] - [choice 5] - [choice 6] - [choice 7]

 

Which is easily translated into an array:

 

ticket[choice 1] = 100
ticket[choice 2] = 200
ticket[choice 3] = etc, etc.

 

Which is easily parsed into a string:

 

for x
{ string .= ticket[x] }

 

Which is also easily inserted and retrieved from a database:

 

for x
{ insert ticket[x] into table }

for x
{ ticket[x] = (get player.ticket[x] from table) }

 

Try it out. You'll be amazed at how much your creativity can be focused on productivity rather than trying to reinvent the wheel.

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.