Created
January 4, 2017 16:10
-
-
Save lkacenja/0399831c7cc18aed868fdcd35743960f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function foop($class_date_nid, $webform_nid) { | |
$sub_query = db_select('webform_submitted_data', 'w'); | |
$sub_query->fields('w', array('sid')); | |
$sub_query->join('webform_component', 'webform_component', 'w.cid=webform_component.cid'); | |
$sub_query->condition('form_key', 'ssl_date_nid', '='); | |
$sub_query->condition('webform_component.nid', $webform_nid, '='); | |
$sub_query->condition('data', $class_date_nid, '='); | |
$query = db_select('webform_submitted_data', 'w'); | |
$query->fields('w', array()); | |
$query->addField('webform_component', 'name', 'name'); | |
$query ->join('webform_component', 'webform_component', 'w.cid=webform_component.cid'); | |
$query->condition('sid', $sub_query, 'IN'); | |
$query->condition('webform_component.nid', $webform_nid, '='); | |
$query->condition('form_key', 'ssl_date_nid', '!='); | |
$resource = $query->execute(); | |
$output = array(); | |
while ($row = $resource->fetchObject()) { | |
$output[$row->sid] = !empty($output[$row->sid]) ? $output[$row->sid] : array(); | |
$output[$row->sid][] = $row; | |
} | |
return array_values($output); | |
} | |
$z = foop(213, 211); | |
$headers = array(); | |
$rows = array(); | |
function ywca_api_get_headers_from_submission($item) { | |
return $item->name; | |
} | |
function ywca_api_get_rows_from_submission($item) { | |
return $item->data; | |
} | |
foreach($z AS $item) { | |
if (empty($headers)) { | |
$headers = array_map('ywca_api_get_headers_from_submission', $item); | |
} | |
$rows[] = array_map('ywca_api_get_rows_from_submission', $item); | |
} | |
$render = array( | |
'#theme' => 'table', | |
'#header' => $headers, | |
'#rows' => $rows | |
); | |
dsm(render($render)); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment