我似乎无法将Wilson Score Confidence SQL代码转换为Codeigniter活动记录代码。这是用于Wilson得分置信度的普通SQL:

SELECT *, ((likes+ 1.9208) / (likes + dislikes) -
                   1.96 * SQRT((likes * dislikes) / (likes + dislikes) + 0.9604) /
                          (likes + dislikes)) / (1 + 3.8416 / (likes + dislikes))
       AS ci_lower_bound FROM widgets WHERE likes + dislikes > 0
       ORDER BY ci_lower_bound DESC;


摘自:http://www.evanmiller.org/how-not-to-sort-by-average-rating.html

这是我尝试的翻译,似乎没有用:

        $this->db->select('*, ((likes + 1.9208) / (likes + dislikes) - 1.96 * SQRT((likes * dislikes) / (likes + dislikes) + 0.9604) / (likes + dislikes)) / (1 + 3.8416 / (likes + dislikes)) AS ci_lower_bound');
        $this->db->where('likes + dislikes >', 0);
        $this->db->order_by("ci_lower_bound", "desc");
        $query = $this->db->get('posts', $config['per_page'], $this->uri->segment(1));
        $data['results'] = $query->result();


结果总是以空结尾。

最佳答案

1.the table name has not been specified in code "widgets"
try:
        $this->db->from('widgets');

关于php - 将Wilson得分置信度SQL代码转换为Codeigniter事件记录,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17086684/

10-11 05:57