In webform-hooks.php, the example hook _webform_analysis_component() should use db_placeholders() to find the number of argument for it's db query.

CommentFileSizeAuthor
#1 webform-1054256.patch707 bytescarinadigital

Comments

carinadigital’s picture

StatusFileSize
new707 bytes

I've attached a patch to use db_placeholders().

quicksketch’s picture

Status: Active » Needs work

Thanks, updating the example to use best-practices is definitely good. Though if you use db_placeholders() that will just create placeholders like IN (%d, %d, %d, %d). You'd need to pass in the $sids variable into the list of arguments in the query to fill in each placeholder.

carinadigital’s picture

I think you already have this in db_query(), webform_hooks.php line 551
Here's the relevant code with the patch;

  $sidfilter = count($sids) ? " AND sid in (" . db_placeholders($sids, 'int') . ")" : "";
  $query = 'SELECT no, data, count(data) as datacount '.
    ' FROM {webform_submitted_data} '.
    ' WHERE nid = %d '.
    ' AND cid = %d '.
    " AND data != '' ". $sidfilter .
    ' GROUP BY no, data';
  $result = db_query($query, array_merge(array($component['nid'], $component['cid']), $sids));
quicksketch’s picture

Status: Needs work » Reviewed & tested by the community

Ha! So I do. How strange. Thanks I'll put this in next time I'm doing patches.

quicksketch’s picture

Component: Code » Documentation
Priority: Normal » Minor
Status: Reviewed & tested by the community » Fixed

Thanks committed. I updated the D7 doc for this same function while I was in there too.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.