Page 1 of 1

problem inserting array in mysql

Posted: Fri Jul 24, 2015 9:59 pm
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:

Re: problem inserting array in mysql

Posted: Fri Jul 24, 2015 10:15 pm
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.

Re: problem inserting array in mysql

Posted: Sat Jul 25, 2015 1:22 am
by mohmedsalem
what a technique can be used in this situation ??