Advertisement
Guest User

SQL QUERY

a guest
Nov 17th, 2022
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. add_action("gform_after_submission", "calculate_total", 10, 2);
  2. function calculate_total( $entry, $form ){
  3. GFCommon::log_debug( __METHOD__ . '(): The Form => ' . print_r( $form, true ) );
  4. GFCommon::log_debug( __METHOD__ . '(): The Entry => ' . print_r( $entry, true ) );
  5. global $wpdb;
  6. $SQL = "UPDATE wp_gf_entry_meta z
  7. INNER JOIN (
  8. Select entry_id, meta_value, sum(meta_value) as total FROM wp_gf_entry_meta where form_id='168' and meta_key like '%135' OR meta_key like '%181' OR meta_key like '%296' OR meta_key like '%346' OR meta_key like '%386' OR meta_key like '%426' OR meta_key like '%546'
  9. group by entry_id
  10. )
  11. g on g.entry_id = z.entry_id
  12. set z.meta_value = g.total
  13. where z.meta_key='82136' and z.form_id='168'";
  14. $result = $wpdb->query($SQL);
  15. GFCommon::log_debug( __METHOD__ . '(): The Result => ' . print_r( $result, true ) );
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement