Computer Science Canada array and database |
Author: | Homer_simpson [ Sun Sep 14, 2003 12:25 pm ] |
Post subject: | array and database |
is it possible to have an array of text as a field in your database? |
Author: | rizzix [ Sun Sep 14, 2003 12:35 pm ] |
Post subject: | |
ur trying to store a complex datatype. if ur database supports it you can. i know oracle does. not sure of mysql. anyhow just convert that array of text to a single string, then store that string. that will work anyhow. |
Author: | Homer_simpson [ Sun Sep 14, 2003 12:40 pm ] | ||
Post subject: | |||
well i'll just do this: Use a text field... and put all my texts there and separate them with a special character like Þ then use this function to break it down into an array:
so now if $text="picture1.jpgÞpicture2.jpgÞsomethingÞ" when i pass it through my function the return array will be like this: arr[0]=picture1.jpg arr[1]=picture2.jpg arr[2]=something hopefully this we'll solve yer problem if u had the same problem as i did.. |
Author: | rizzix [ Sun Sep 14, 2003 12:56 pm ] |
Post subject: | |
eh what!!! u solved ur own problem thats nice |
Author: | Homer_simpson [ Sun Sep 14, 2003 1:23 pm ] |
Post subject: | |
rizzix wrote: eh what!!! u solved ur own problem thats nice
lol... i knew how to do that.... i wanted to know if there's a proper way to di it so i wouldn't have to extract strings from eachother... |
Author: | octopi [ Sun Sep 14, 2003 1:43 pm ] |
Post subject: | |
I am pretty sure this is what you want. http://ca.php.net/serialize http://ca.php.net/unserialize |
Author: | PaddyLong [ Sun Sep 14, 2003 1:49 pm ] |
Post subject: | |
heh you do know that php provides a function to split strings into an array at certain a expression? split ... http://ca2.php.net/manual/en/function.split.php |
Author: | Homer_simpson [ Sun Sep 14, 2003 2:55 pm ] |
Post subject: | |
PaddyLong wrote: heh you do know that php provides a function to split strings into an array at certain a expression? split ... http://ca2.php.net/manual/en/function.split.php
lol... no i had no idea that php does that... but i'm still happy with the way i'm working my database and separating them manually... |
Author: | rizzix [ Sun Sep 14, 2003 9:30 pm ] |
Post subject: | |
if i were you, i'd go with octopi's recommendation: serialization. Since using that method you can even store Objects in the database. |
Author: | Homer_simpson [ Mon Sep 15, 2003 5:48 pm ] |
Post subject: | |
well yes that's not a bad idea... but currently all i need is to save simple strings into a field and i find sperating the strings easier to do... but if i wanna store more complex data then i'll use that method... |
Author: | octopi [ Mon Sep 15, 2003 6:58 pm ] | ||
Post subject: | |||
First off you make no sense in your posts, and you keep contradicting yourself....and heres an anwser using the methods I explained.....I don't see how this is harder or more complex...it does the exact thing, but in a better way, and probally more efficient way.
Untested because...I am not going to put that much effort into a solution for you. Why would you ask for an anwser to a question you have already solved...and then not even use the anwsers... |