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. Link to comment https://forums.phpfreaks.com/topic/16410-sql-syntax-for-an-array/ 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? Link to comment https://forums.phpfreaks.com/topic/16410-sql-syntax-for-an-array/#findComment-68549 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. Link to comment https://forums.phpfreaks.com/topic/16410-sql-syntax-for-an-array/#findComment-68785 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. Link to comment https://forums.phpfreaks.com/topic/16410-sql-syntax-for-an-array/#findComment-68797 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. Link to comment https://forums.phpfreaks.com/topic/16410-sql-syntax-for-an-array/#findComment-68854 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). Link to comment https://forums.phpfreaks.com/topic/16410-sql-syntax-for-an-array/#findComment-68896 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. Link to comment https://forums.phpfreaks.com/topic/16410-sql-syntax-for-an-array/#findComment-75923 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.