problem inserting array in mysql

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
mohmedsalem
Forum Newbie
Posts: 2
Joined: Fri Jul 24, 2015 9:44 pm

problem inserting array in mysql

Post by mohmedsalem »

hi guys, i want to ask how can i store an array in mysql field without mysql convert it to a normal string, i tried to make serialize on that array and store it but it still giving me it like string not an array so, i can't use arrays function like in_array() because the result that coming from the database is not array it's store it like string and fetch it in string also , i am working on rating script and i wanna to store the user id in array after he voted to prevent voting again using in_array() function to check if it's in that array or not , i am really want to know how to store an array in mysql filed without mysql convert it to string i wanna to save it from converting ... can any one help me please, and thank you again.
:cry:
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: problem inserting array in mysql

Post by Celauran »

You can't store an array in a database but, more importantly, you probably don't want to.
i am working on rating script and i wanna to store the user id in array after he voted to prevent voting again
You can use either a flag on the user's account or create an entry in a pivot table, depending on the use case. Both of these would be better solutions.
mohmedsalem
Forum Newbie
Posts: 2
Joined: Fri Jul 24, 2015 9:44 pm

Re: problem inserting array in mysql

Post by mohmedsalem »

what a technique can be used in this situation ??
Post Reply