WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form DB
Concatenate (4 posts)

  1. 9yu9
    Member
    Posted 1 year ago #

    I'm tying to create a query to combine multiple fields with concat_ws().
    But I'm not sure how to proceed, since field data are stored in a single column in CFDB.

    For example, I have a field Hour with a value of '7', and a field Minute with a value of '30'. I'd like to use concat_ws() to output '7:30'.

    http://wordpress.org/extend/plugins/contact-form-7-to-database-extension/

  2. Michael Simpson
    Member
    Plugin Author

    Posted 1 year ago #

    The plugin does not allow you to use a MySQL function call. But you have a couple options.

    1. Inbound: When a form is posted, you can concatenate these values into one value so that it is stored as a single field in the DB. There is an example of on this page.

    2. Outbound: Assuming the data is stored in different fields and you are using [cfdb-html] to display the data, you can effectively concatenate them:
    [cfdb-html form="form_name"]${hour_field}:${minute_fields} [/cfdb-html]

    I figure #1 is generally preferable.

  3. Mr. Bingo
    Member
    Posted 1 year ago #

    I need to create a "record ID" for each entry in my database. If I create the form with an ID field, that field will show in the form, which I don't want. I assumed that I could use this solution #1 above (or something like it). Is that true, or is there an alternate solution for establishing a record ID?

  4. Michael Simpson
    Member
    Plugin Author

    Posted 1 year ago #

    The form submissions already have an id. It is the "submit_time" field which is just a number. When you look at the admin page you see "Submitted" which is that value formatted as a human readable date. "submit_time" is a timestamp of when the form was submitted down to the microsecond.

    In short codes you can output "submit_time" as well by adding it to "show" like [cfdb-table form="form_name" show="submit_time"]

    If you want to create your own ID, you would need to create a filter (#1 above) and add an "id" field like: $formData->posted_data['id'] = uniqid();

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.