Welcome Guest, Not a member yet? Register   Sign In
Javascript - array of objects, exchage values
#4

[eluser]SPeed_FANat1c[/eluser]
Just made change with codeigniter and sql. It is so much faster to code it.

Code:
function move_down($link_id)
    {
        //find a place of link with current id
          $query = $this->db->select('vieta')->where('link_id',$link_id)->get('nuorodos');
          $row = $query->row();
          $place = $row->vieta;

          //find an id of lower link
          
          $query = $this->db->select('link_id')->where('vieta',$place+1)->get('nuorodos');
          $row = $query->row();
          $lower_link_id  = $row->link_id;
          
          //assign a new place for the current link
                    
          $data = array(
              'vieta' => $place + 1
          );
          $query = $this->db->where('link_id',$link_id)->update('nuorodos', $data);
          
          //assign a new place for lower link
          if($query)
          {
              $data = array(
                  'vieta' => $place
              );
              $query = $this->db->where('link_id',$lower_link_id)->update('nuorodos', $data);
            
              if($query)
                  $return_value = 'ok';
              else $return_value = 'change_not_made';
          }
          else $return_value = 'change_not_made';
          
          return $return_value;
    }

I would like to ask is it necessary to check if update was succesfull? Those additional checking lines look not nice, and it is so litte chance that sql server will shut down or something. How do you think?


Messages In This Thread
Javascript - array of objects, exchage values - by El Forum - 12-14-2010, 09:49 AM
Javascript - array of objects, exchage values - by El Forum - 12-14-2010, 10:42 AM
Javascript - array of objects, exchage values - by El Forum - 12-14-2010, 11:30 AM
Javascript - array of objects, exchage values - by El Forum - 12-15-2010, 06:57 AM



Theme © iAndrew 2016 - Forum software by © MyBB