function _webform_fetch_submissions in Webform 5
Return all the submissions for a particular node.
Parameters
$nid: The node ID for which submissions are being fetched.
$header: If the results of this fetch will be used in a sortable table, pass the array header of the table.
3 calls to _webform_fetch_submissions()
- _webform_results_download in ./
webform_report.inc - Generate a Excel-readable CSV file containing all submissions for a webform.
- _webform_results_submissions in ./
webform_report.inc - Retrieve lists of submissions for a given webform.
- _webform_results_table in ./
webform_report.inc - Create a table containing all submitted values for a webform node.
File
- ./
webform.inc, line 112
Code
function _webform_fetch_submissions($nid, $header = NULL) {
$query = 'SELECT s.*, sd.cid, sd.no, sd.data, u.name, u.mail, u.status ' . 'FROM {webform_submissions} s ' . 'LEFT JOIN {webform_submitted_data} sd ON sd.sid = s.sid ' . 'LEFT JOIN {users} u ON u.uid = s.uid ' . 'WHERE sd.nid = %d';
if (is_array($header)) {
$query .= tablesort_sql($header);
}
$res = db_query($query, $nid);
$submissions = array();
$previous = array();
// Outer loop: iterate for each submission.
while ($row = db_fetch_object($res)) {
if ($row->sid != $previous) {
$submissions[$row->sid]->sid = $row->sid;
$submissions[$row->sid]->submitted = $row->submitted;
$submissions[$row->sid]->remote_addr = $row->remote_addr;
$submissions[$row->sid]->uid = $row->uid;
$submissions[$row->sid]->name = $row->name;
$submissions[$row->sid]->status = $row->status;
}
$submissions[$row->sid]->data[$row->cid]['value'][$row->no] = $row->data;
$previous = $row->sid;
}
return $submissions;
}