select score, count(*) as distribution from answers where quiz_id_fk='19' group by score order by score asc;
public function answerDistribution($quiz_id) {
$this->distribution = 'COUNT(*)';
return $this->find(['quiz_id_fk = ?', $quiz_id], ['group' => 'score', 'order' => 'score asc']);
}
<?php
class Answers extends DB\SQL\Mapper{
public function __construct(DB\SQL $db) {
parent::__construct($db,'answers');
}
// ... other functions
public function answerDistribution($quiz_id) {
return $this->select('score, count(*) as distribution','quiz_id_fk = '. $quiz_id,['group' => 'score', 'order' => 'score asc'] );
}
}
$distribution = new Answers($this->db);
$this_distribution = $distribution->answerDistribution($id);
$f3->set('distribution',$this_distribution);
$this->distribution = 'COUNT(*)';
then use this instead:
return $this->select('
score
',['quiz_id_fk = ?', $quiz_id], ['group' => 'score', 'order' => 'score asc']);
<repeat group="{{@distribution}}" value="{{@reocrd}}">
<p>{{@record.score}} - {{@record.distribution}}</p>
</repeat>
$this_distribution = $distribution->answerDistribution($id);
foreach($this_distribution as $record)
var_dump($record->cast());
--To view this discussion on the web visit https://groups.google.com/d/msgid/f3-framework/5fcd02de-76fd-495d-920a-e6f0b04b2b23%40googlegroups.com.
-- You've received this message because you are subscribed to the Google Groups group. To post to this group, send an email to f3-fra...@googlegroups.com. To unsubscribe from this group, send an email to f3-framework+unsubscribe@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/f3-framework?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "Fat-Free Framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/f3-framework/dmxygGNoi7c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to f3-framework+unsubscribe@googlegroups.com.
To post to this group, send email to f3-fra...@googlegroups.com.
Visit this group at https://groups.google.com/group/f3-framework.