コード例 #1
0
 public function sortValues($id, $direction)
 {
     // Get current sort value
     $q = "SELECT sort_order FROM category WHERE id = " . $id;
     $r = parent::returnresultSet($q);
     $l = $r[0];
     $sortVal = $l->sort_order;
     if ($direction == 'U') {
         // Move item that is currently in the new position to this item's position
         $q = "UPDATE category SET sort_order = " . $sortVal . " WHERE sort_order = " . ($sortVal - 10);
         parent::updateQuery($q);
         // Put selected item in new position
         $q = "UPDATE category SET sort_order = " . ($sortVal - 10) . " WHERE id = " . $id;
         parent::updateQuery($q);
     } else {
         // Move item that is currently in the new position to this item's position
         $q = "UPDATE category SET sort_order = " . $sortVal . " WHERE sort_order = " . ($sortVal + 10);
         parent::updateQuery($q);
         // Put selected item in new position
         $q = "UPDATE category SET sort_order = " . ($sortVal + 10) . " WHERE id = " . $id;
         parent::updateQuery($q);
     }
 }
コード例 #2
0
 public function sortValues($id, $direction)
 {
     // Get current sort value
     $q = "SELECT technology_info_id, sort_order FROM technology_info_image WHERE id = " . $id;
     $r = parent::returnresultSet($q);
     $l = $r[0];
     $sortVal = $l->sort_order;
     $technology_info_id = $l->technology_info_id;
     if ($direction == 'U') {
         // Move item that is currently in the new position to this item's position
         $q = "UPDATE technology_info_image SET sort_order = " . $sortVal . " WHERE technology_info_id = " . $technology_info_id . " AND sort_order = " . ($sortVal - 10);
         parent::updateQuery($q);
         // Put selected item in new position
         $q = "UPDATE technology_info_image SET sort_order = " . ($sortVal - 10) . " WHERE id = " . $id;
         parent::updateQuery($q);
     } else {
         // Move item that is currently in the new position to this item's position
         $q = "UPDATE technology_info_image SET sort_order = " . $sortVal . " WHERE technology_info_id = " . $technology_info_id . " AND sort_order = " . ($sortVal + 10);
         parent::updateQuery($q);
         // Put selected item in new position
         $q = "UPDATE technology_info_image SET sort_order = " . ($sortVal + 10) . " WHERE id = " . $id;
         parent::updateQuery($q);
     }
 }