models/opiniarbo_model.php
changeset 4 fcb273554da6
parent 3 f3e55c2386a1
child 5 cb13c07e7e5d
--- a/models/opiniarbo_model.php	Sun Dec 28 16:57:53 2008 +0000
+++ b/models/opiniarbo_model.php	Sun Dec 28 17:20:55 2008 +0000
@@ -207,7 +207,7 @@
 
     function recalc_user_influences($user,$parent)
     {
-        $this->db->select('values.id,values.influence');
+        $this->db->select('values.id as vid,asertoj.id,values.influence');
         $this->db->from('values');
         $this->db->join('asertoj','values.assertion = asertoj.id');
         $this->db->where('asertoj.parent',$parent);
@@ -235,7 +235,7 @@
                 if ($parent != NULL)
                 {
                     $newinfluence = $row['influence'] / $sum_influence;
-                    $query2 = $this->db->where('id', $row['id']);
+                    $query2 = $this->db->where('id', $row['vid']);
                     $query2->update('values', array(
                                 'influence' => $newinfluence));
                 }
@@ -246,7 +246,7 @@
 
     function get_user_calc_value($user, $parent, $orig_value)
     {
-        $this->db->select('values.id,values.value,values.influence');
+        $this->db->select('asertoj.id,values.id as vid,values.value,values.influence');
         $this->db->from('values');
         $this->db->join('asertoj','values.assertion = asertoj.id');
         $this->db->where('asertoj.parent',$parent);
@@ -278,9 +278,9 @@
         // and the proper value to those with subassertions.
         if ($parent != NULL)
         {
-            $query2 = $this->db->where('id', $parent);
-            $query2->update('values', array(
-                        'calc_value' => $val, 'user' => $user));
+            $query2 = $this->db->where('assertion', $parent);
+            $query2 = $this->db->where('user', $user);
+            $query2->update('values', array('calc_value' => $val));
         }
 
         if ($val == NULL)