I’ve read as much as I can find on the forum about using a session variable (regular variable without using var) and global media types to store arrays, but I can’t seem to find anything about a way to drop an array into a column in a table for later recall (in a different session). I haven’t actually gotten global media types to work in storing and recalling arrays, and similarly a column of type media doesn’t seem to work for me.
I’m trying to save search requests by storing the SQL and SQL Params in two columns in a savedsearches table. Can someone let me know what I’m doing wrong?
The only thing I’ve gotten to work is to .join them into a text string delimited by a comma and store them that way. When I feed them back in though the array looks correct in debugger, it only works if I’ve only got one param.
Thanks in advance.
Just assining an array to a (global)variable should do the trick within a session:
globals.xxx = new Array()
yyy = new Array()
Ofcourse, the global needs to be of type = media.
If you want to store an array in a databasecolumn, you can convert the array to a string using the JSOn plugin, save it in a text column. You can use the same plugin to reverse the process.
You can also add a converter to the column so you can set the array directly and the convertor does the translation. The converter is basically 2 methods which you write to do the conversion.
Hope this gets you started.
Paul
Thanks for the start Paul …
I’d love to use the JSOn plugin, but this is for a huge client that takes eons to authorize $149.
I already have it storing as a text string using .join – isn’t there any way to .push it back into an array without a plugin? .push itself doesn’t seem to work, though I’m not above breaking apart my text string using stringLeft etc if I must… I just can’t imagine it’s really necessary? Where can I get a look at the “converter” 2 methods you mention?
ellen
The JSon plugin is shipped with Servoy, offcourse free of charge ![Smile :-)]()
You can split a string into an array using string.split(“x”) //x being your separator.
Depending on the type of data this offcourse can go horribly wrong if the data contains the same character as what you used as separator.
The convertor settings are on column level, so open the table and then the column. Same location where you set the sequence of a column for example.
Paul
ah, the json plugin is called serialize ![Smile :-)]()
Found the serialize plugin – didn’t realize it was already included with Servoy and kept searching the forum for it. SMART! Thanks – it works now perfectly!
ellen