Created
November 14, 2013 17:37
-
-
Save lkacenja/7470985 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 | |
// Get All Airings BY Project Per Range | |
$start = 1383845472; | |
$end = 1384450272; | |
$query = db_select('field_data_field_om_airing_dates', 'dates'); | |
$query->join('field_data_field_om_show_id', 'om_show', 'dates.entity_id=om_show.entity_id'); | |
$query->join('field_data_field_om_show_project', 'project', 'om_show.field_om_show_id_value=project.entity_id'); | |
$query->fields('project', array('field_om_show_project_nid')); | |
$query->addExpression('COUNT(field_om_show_project_nid)', 'airings'); | |
$query->condition('dates.field_om_airing_dates_value', $start, '>='); | |
$query->condition('dates.field_om_airing_dates_value2', $end, '<='); | |
$query->groupBy('project.field_om_show_project_nid'); | |
$query->orderBy('airings', 'DESC'); | |
dpq($query); | |
$resource = $query->execute(); | |
$result = $resource->fetchAll(); | |
dsm($result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment