Skip to content

Instantly share code, notes, and snippets.

Created November 30, 2015 22:11
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
sql select
<? php
public static function getAllIndicatorValuesOverview($userId = null) {
$surveys = self::getConnection()->query(
'SELECT surveys.surveyId,surveys.year,user.organizationName
FROM surveys
LEFT JOIN user ON surveys.userId=user.userId'
foreach($surveys as &$survey) {
$indicators = self::getConnection()->query(
FROM indicator
LEFT JOIN indicatorvalue ON indicator.indicatorId=indicatorvalue.indicatorId
WHERE indicatorvalue.surveyId=?', $survey['surveyId']
foreach($indicators as $indicator) {
$survey[$indicator['name']] = $indicator['value'];
$survey = (array) $survey;
return $surveys;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment