The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
storing arrays
is there a superior method to serialize?
can i just store an array straight into a db = [sql] INSERT INTO table(col1, col2) VALUES ('hello', 'array([greet]=>hello, [bye]=>bye)') [/sql] |
#2
|
||||
|
||||
No, you need to serialize it. the process to get the query data returned and evaled as php code again would be more costly than serialize. Serialize is not as efficient as it could be, but it's not the devil everyone makes it out to be either. It's a useful tool that serves a purpose.
|
#3
|
||||
|
||||
If it's text data you could implode it into a string (with a suitable seperator) and explode it when you pull it from the db - but I'm not sure this method would be any better.
|
#4
|
||||
|
||||
thanks guys, i decided on the serialize in the late/early hours of last night, but just to give you an idea of what i'm doing
[sql]INSERT INTO ej_moodset(title, author, location, moods) VALUES ('Hamsters', 'r2d2', 'images/ej/moods/r2d2__hamsters', 'a:127:{s:11:"Acomplished";s:15:"Acomplished.gif"; s:10:"Aggrivated";s:14:"Aggrivated.gif";s:6:"Amuse d";s:10:"Amused.gif";s:5:"Angry";s:9:"Angry.gif";s :9:"Apethetic";s:13:"Apethetic.gif";s:8:"Artistic" ;s:12:"Artistic.gif";s:5:"Awake";s:9:"Awake.gif";s :6:"+++++y";s:10:"+++++y.gif";s:4:"Blah";s:8:"Blah .gif";s:5:"Blank";s:9:"Blank.gif";s:5:"Bored";s:9: "Bored.gif";s:6:"Bouncy";s:10:"Bouncy.gif";s:4:"Bu sy";s:8:"Busy.gif";s:4:"Calm";s:8:"Calm.gif";s:9:" Cheerfull";s:13:"Cheerfull.gif";s:7:"Chipper";s:11 :"Chipper.gif";s:4:"Cold";s:8:"Cold.gif";s:10:"Com placent";s:14:"Complacent.gif";s:8:"Confused";s:12 :"Confused.gif";s:13:"Contemplative";s:17:"Contemp lative.gif";s:7:"Content";s:11:"Content.gif";s:6:" Cranky";s:10:"Cranky.gif";s:6:"Crappy";s:10:"Crapp y.gif";s:5:"Crazy";s:9:"Crazy.gif";s:8:"Creative"; s:12:"Creative.gif";s:7:"Crushed";s:11:"Crushed.gi f";s:7:"Curious";s:11:"Curious.gif";s:7:"Cynical"; s:11:"Cynical.gif";s:9:"Depressed";s:13:"Depressed .gif";s:10:"Determined";s:14:"Determined.gif";s:7: "Devious";s:11:"Devious.gif";s:5:"Dirty";s:9:"Dirt y.gif";s:10:"Discontent";s:14:"Discontent.gif";s:1 3:"Dissappointed";s:17:"Dissappointed.gif";s:10:"D istressed";s:14:"Distressed.gif";s:5:"Ditzy";s:9:" Ditzy.gif";s:5:"Dorky";s:9:"Dorky.gif";s:7:"Draine d";s:11:"Drained.gif";s:5:"Drunk";s:9:"Drunk.gif"; s:10:"Embaressed";s:14:"Embaressed.gif";s:9:"energ etic";s:13:"energetic.gif";s:7:"Enraged";s:11:"Enr aged.gif";s:10:"Enthralled";s:14:"Enthralled.gif"; s:7:"Envious";s:11:"Envious.gif";s:7:"Estatic";s:1 1:"Estatic.gif";s:9:"Exhausted";s:13:"Exhausted.gi f";s:6:"Flirty";s:10:"Flirty.gif";s:4:"Full";s:8:" Full.gif";s:9:"Fustrated";s:13:"Fustrated.gif";s:5 :"Geeky";s:9:"Geeky.gif";s:5:"Giddy";s:9:"Giddy.gi f";s:6:"Giggly";s:10:"Giggly.gif";s:6:"Gloomy";s:1 0:"Gloomy.gif";s:4:"Good";s:8:"Good.gif";s:9:"grat efull";s:13:"gratefull.gif";s:6:"Groggy";s:10:"Gro ggy.gif";s:6:"Grumpy";s:10:"Grumpy.gif";s:6:"Guilt y";s:10:"Guilty.gif";s:5:"Happy";s:9:"Happy.gif";s :4:"High";s:8:"High.gif";s:8:"Hopefull";s:12:"Hope full.gif";s:5:"Horny";s:9:"Horny.gif";s:3:"Hot";s: 7:"Hot.gif";s:6:"Hungry";s:10:"Hungry.gif";s:5:"Hy per";s:9:"Hyper.gif";s:9:"Impressed";s:13:"Impress ed.gif";s:13:"Indescribable";s:17:"Indescribable.g if";s:11:"Indifferent";s:15:"Indifferent.gif";s:10 :"infuriated";s:14:"infuriated.gif";s:11:"Intimida ted";s:15:"Intimidated.gif";s:5:"Irate";s:9:"Irate .gif";s:9:"Irritated";s:13:"Irritated.gif";s:7:"Je alous";s:11:"Jealous.gif";s:8:"Jubilant";s:12:"Jub ilant.gif";s:4:"Lazy";s:8:"Lazy.gif";s:8:"Listless ";s:12:"Listless.gif";s:6:"Lonely";s:10:"Lonely.gi f";s:5:"Loved";s:9:"Loved.gif";s:10:"Melancholy";s :14:"Melancholy.gif";s:6:"Mellow";s:10:"Mellow.gif ";s:11:"Mischevious";s:15:"Mischevious.gif";s:5:"M oody";s:9:"Moody.gif";s:6:"Morose";s:10:"Morose.gi f";s:7:"Naughty";s:11:"Naughty.gif";s:9:"Nausiated ";s:13:"Nausiated.gif";s:5:"Nerdy";s:9:"Nerdy.gif" ;s:7:"Nervous";s:11:"Nervous.gif";s:9:"Nostalgic"; s:13:"Nostalgic.gif";s:4:"Numb";s:8:"Numb.gif";s:2 :"Ok";s:6:"Ok.gif";s:10:"optimistic";s:14:"optimis tic.gif";s:9:"Peacefull";s:13:"Peacefull.gif";s:7: "Pensive";s:11:"Pensive.gif";s:11:"Pessimistic";s: 15:"Pessimistic.gif";s:10:"Pissed_Off";s:14:"Pisse d_Off.gif";s:7:"Pleased";s:11:"Pleased.gif";s:9:"P redetary";s:13:"Predetary.gif";s:10:"Productive";s :14:"Productive.gif";s:8:"Quixotic";s:12:"Quixotic .gif";s:9:"Recumbent";s:13:"Recumbent.gif";s:9:"Re freshed";s:13:"Refreshed.gif";s:8:"Rejected";s:12: "Rejected.gif";s:11:"Rejuvinated";s:15:"Rejuvinate d.gif";s:7:"Relaxed";s:11:"Relaxed.gif";s:7:"Reliv ed";s:11:"Relived.gif";s:8:"Restless";s:12:"Restle ss.gif";s:6:"Rushed";s:10:"Rushed.gif";s:3:"Sad";s :7:"Sad.gif";s:9:"Satisfied";s:13:"Satisfied.gif"; s:6:"Scared";s:10:"Scared.gif";s:7:"Shocked";s:11: "Shocked.gif";s:4:"Sick";s:8:"Sick.gif";s:5:"Silly ";s:9:"Silly.gif";s:6:"Sleepy";s:10:"Sleepy.gif";s :4:"Sore";s:8:"Sore.gif";s:8:"Stressed";s:12:"Stre ssed.gif";s:9:"Surprised";s:13:"Surprised.gif";s:1 1:"Sympathetic";s:15:"Sympathetic.gif";s:9:"thankf ull";s:13:"thankfull.gif";s:7:"Thirsty";s:11:"Thir sty.gif";s:11:"Thoughtfull";s:15:"Thoughtfull.gif" ;s:5:"Tired";s:9:"Tired.gif";s:7:"Touched";s:11:"T ouched.gif";s:13:"uncomfortable";s:17:"uncomfortab le.gif";s:5:"Wierd";s:9:"Wierd.gif";s:7:"Working"; s:11:"Working.gif";s:7:"Worried";s:11:"Worried.gif ";}')[/sql] the query consists of like 17 of those, 35,000 characters long but only 0.0117 seconds to execute. however retreival goes a little something like this PHP Code:
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|