Basically when each video watched it is stored for each user in playlist mysql table.
What is really bad: there is no limit how many records are stored in playlist table!
So in my personal database I found millions of records in this table.
Altering such table can really be bad for your mysql.
Unfortunately there's no way to limit playlist entries number when saving or reading records.
So what I did was to rebuild playlist table, added unique autoincrement field ID.
Then when storing new video or reading it, first I check if records number doesn't exceed my limit (I set 100 for each user). If so - using one mySQL query I remove oldest records above limit number.
For those that do not have so much experience with MySQL - I suggest to remove all code that stores video into playlist table. It's file "view_video.php" and code to remove is:
- Code: Select all
$sql = "INSERT INTO playlist SET UID = '" .$uid. "' , VID = '" .$VID. "'";
$conn->execute($sql);
D.