• Resolved andywt

    (@andywt)


    Michael,
    Fantastic plugin with many great features!!

    My application is passing two variables via an URL that identify an uniqueID and provide a value for an updated field. I’ve got my variable passing working but am struggling with the sql query and subsequent update.

    I started by simply using the generated query to make sure my sql is working and it does work. The trouble comes when I add the SQL query outside the generated query. Then nothing is returned. My code looks like:

    SELECT * FROM
         <generated query goes here>
    WHERE 'UniqueID' = $uniqueID

    UniqueID is the DB field name and $uniqueID is the passed variable.

    Is there anything special that has to go in the query outside the generated query?

    Any code tidbits on updating the record I do finally SELECT?

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter andywt

    (@andywt)

    I believe my issue is that I am using the $wpdb->get_results to perform the sql query so it can not handle nested selects. So I made this change:

    $dbarray = $wpdb->get_results("Select... this is the generated query)
    $query = $wpdb->get_results ("Select * FROM $dbarray WHERE <code>UniqueDB</code> = $uniqueID");

    The $dbarray contains the entire DB but $query is null. I do know that there is a record that matches the WHERE condition. I have also tried other fields in the database but nothing is ever retrieved.

    Plugin Author Michael Simpson

    (@msimpson)

    I recommend against access the data via SQL directly. Use the API instead.

    http://cfdbplugin.com/?page_id=367

    Thread Starter andywt

    (@andywt)

    Michael,
    Thanks for the advice. Any advice on updating the contact form data from PHP?

    Plugin Author Michael Simpson

    (@msimpson)

    No APIs specifically for that.

    Thread Starter andywt

    (@andywt)

    Addressed the issue by direct access to the $wpdb.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘mySQL Query issues’ is closed to new replies.