wiki:RemoveComponentFromBuild

Version 5 (modified by 233051, 18 hours ago) ( diff )

--

Remove component from build

Actors

User, Admin

Scenario

  1. In the forge, after the user chooses the desired existing component they click on the trash can icon

  1. The server removes the component from the build
BEGIN;

SELECT *
FROM build
WHERE id = $buildId
  AND user_id = $userId
LIMIT 1;

DELETE FROM build_component
WHERE build_id = $buildId
  AND component_id = $componentId;

SELECT c.price
FROM build_component bc
JOIN components c ON c.id = bc.component_id
WHERE bc.build_id = $buildId;

UPDATE build
SET total_price = (
  SELECT COALESCE(ROUND(SUM(c.price), 2), 0)
  FROM build_component bc
  JOIN components c ON c.id = bc.component_id
  WHERE bc.build_id = $buildId
)
WHERE id = $buildId;

COMMIT;

Attachments (2)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.