An MySQL Procedure for ampache

Below is an procedure used to insert data to the rating of ampache for initialization purpose.

DROP PROCEDURE IF Exists initRatingForXo;

delimiter //
CREATE PROCEDURE initRatingForXo()
BEGIN
DECLARE max INT;
DECLARE curss INT;
SET max = 17193;
SET curss = 0;
start transaction;
WHILE max > curss DO
SET curss = curss + 1;
insert into rating (user,object_type,object_id,rating) values ( 2,'song',curss ,0);
END WHILE;
commit;
END//# MySQL returned an empty result set (i.e. zero rows).

delimiter ;
call initRatingForXo();

And then set rating by user and playlist id:

UPDATE rating SET rating =5 WHERE object_id IN (
SELECT object_id
FROM playlist_data
WHERE playlist =12
AND object_type = "song"
)
AND user =2

English

Add new comment