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.


Link to comment
Share on other sites

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
Share on other sites

  • 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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.