In the wp_rg_lead_detail table, taken together are the three columns "lead_id", "form_id", and "field_number" always unique?
In the wp_rg_lead_detail table, taken together are the three columns "lead_id", "form_id", and "field_number" always unique?
Yes, combined, those three fields can form a unique key. For one form and one lead, there can only be one value stored for a field_number.
Perfect. By the way, does gravity forms provide an API to update a set of these rows? (I'm trying to figure out how to update a set of these values and if it doesn't exist, create a new row.)
...happy to just have you answer, "we don't support that." Thanks for the help regarding my orginal question!
There is no API really. The best documentation for the plugin is the plugin files themselves. If you can explain your use case, maybe we can come up with more ideas for you.
I've created an form that updates enteries of another form. I hook into the submission, and custom process it, updating the database with a query like such: http://pastebin.com/cnp8P5HA
The problem is, with this query, if the original form did not create a new row (for instance if the field was empty), then this data is not updated (because it doesn't exisit to be update.)
So I'm trying to come up with an elegant solution. I was thinking ON DUPLICATE KEY UPDATE might work, but the current database structure doesn't seem (in my limited sql experience) to jive with it as I need knowledge of the primary_key.
Perhaps you have an idea, or perhaps you could show me where the code exists to update the exisiting form from the admin area.
Just to be sure I follow along, with this question:
Perhaps you have an idea, or perhaps you could show me where the code exists to update the exisiting form from the admin area.
Do you mean the code to update an existing entry in the admin? If so, you can look at forms_model.php around line 798 for the function save_lead:
[php]
public static function save_lead($form, &$lead){
That might give you some clues.
Yup, thanks.