ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Writing queries using field names, not ID numbers

February 04, 2009 12:45am

Subscribe [3]
  • #1 / Feb 04, 2009 12:45am

    Jesse B.

    33 posts

    Is there any way to write a SQL query that selects/inserts/updates data in a weblog without requiring a separate query to get the field IDs?  I’m interested in doing something like this:

    SELECT (
        SELECT CONCAT("field_id_", field_id)
        FROM exp_weblog_fields
        WHERE field_name = "blog-reviewed"
    ) AS blog_reviewed_values
    FROM exp_weblog_data;

    I want blog_reviewed_values to be the values from the appropriate column from the exp_weblog_data table, not the string “field_id_4.”

    Thanks in advance for the help.

  • #2 / Feb 10, 2009 9:50pm

    Jesse B.

    33 posts

    (bump)

    If anybody has any insights on this problem, I could use the help.  If I don’t hear back, I may just admit defeat and hard-code the field IDs, but I’m hoping I can automate it for future-proofing.

    Thanks again.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases