Created
October 27, 2018 16:11
-
-
Save podolinek/e1e5e19bd723a37be20dcf3579329988 to your computer and use it in GitHub Desktop.
sql select
This file contains hidden or 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 | |
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' | |
)->fetchAll(); | |
foreach($surveys as &$survey) { | |
$indicators = self::getConnection()->query( | |
'SELECT indicator.name,indicatorvalue.value | |
FROM indicator | |
LEFT JOIN indicatorvalue ON indicator.indicatorId=indicatorvalue.indicatorId | |
WHERE indicatorvalue.surveyId=?', $survey['surveyId'] | |
)->fetchAll(); | |
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