Skip to content

Instantly share code, notes, and snippets.

@KrotovRoman
Created June 26, 2018 11:11
Show Gist options
  • Select an option

  • Save KrotovRoman/5ca91f9f190f09bd8fd1fba49728a634 to your computer and use it in GitHub Desktop.

Select an option

Save KrotovRoman/5ca91f9f190f09bd8fd1fba49728a634 to your computer and use it in GitHub Desktop.
подсчитать за какой файл больше всего проголосовали
public function get_winner_opros($id_opros) {
$this->db->limit(1);
$this->db->select('id_file, count(*) as count');
$this->db->group_by('id_file');
$this->db->order_by('count', 'desc');
$this->db->where('id_opros', $id_opros);
$files_votes = $this->db->get('files_votes');
if ($files_votes->num_rows() <= 0) {
return FALSE;
}
return $files_votes->row()->id_file;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment