AncientSage Posted August 3, 2006 Share Posted August 3, 2006 Hello,What is the SQL syntax for an array? I've been searching Google for the past hour, and other has turned up. Additionally, if someone could tell me how to put like...more than one string into that array, thanks. Quote Link to comment Share on other sites More sharing options...
fenway Posted August 3, 2006 Share Posted August 3, 2006 Huh? Perhaps you mean an IN clause? Could you give an example? Quote Link to comment Share on other sites More sharing options...
AncientSage Posted August 3, 2006 Author Share Posted August 3, 2006 [code]INSERT INTO config (config_name, config_value) VALUES ('allowed_file_ext', '{\.mid, \.mp3, \.wav, \.aiff}');[/code]Where {\.mid, \.mp3, \.wav, \.aiff} is supposed to be the array (each item in the array seperated by a comma), but I don't believe it is working as I want it to. Quote Link to comment Share on other sites More sharing options...
fenway Posted August 3, 2006 Share Posted August 3, 2006 Yeah, there is no such thing... if you're selecting some from a predefined set, you could use ENUM/SET, but it makes more sense to have one record per pair of name/value. If that doesn't suffice, you'll need to insert some string that can be subsequently parsed, but that's not always better, and much harder to maintain. Quote Link to comment Share on other sites More sharing options...
king arthur Posted August 3, 2006 Share Posted August 3, 2006 Try imploding the array into a single string value with some separator that won't cause you problems, and then exploding it when you pull it out of the database again. Quote Link to comment Share on other sites More sharing options...
fenway Posted August 4, 2006 Share Posted August 4, 2006 That will work, of course -- just consider the long-term implications (i.e. impossible to search properly, hard to edit, etc). Quote Link to comment Share on other sites More sharing options...
GoinNuts Posted August 16, 2006 Share Posted August 16, 2006 My suggestion would be to keep the fields in the SQL table as distinct values (as opposed to parsing them into a delimited string). If you need to work with the values in an array within your php code, populate the array from the result of the query on the fly. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.