Jump to content

SQL syntax for an array?


AncientSage

Recommended Posts

[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.


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.
  • 2 weeks later...
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.