Skip to content
This repository has been archived by the owner on Jan 6, 2020. It is now read-only.

Commit

Permalink
Fix update.php failing with MySQL
Browse files Browse the repository at this point in the history
MySQL doesn't support the DELETE syntax introduced in commit 15ffa09.
This fixes fossar#298.
  • Loading branch information
seanrand committed Apr 28, 2013
1 parent 46cb4e7 commit bf8b501
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
5 changes: 2 additions & 3 deletions daos/mysql/Items.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,8 @@ public function exists($uid) {
* @param DateTime $date date to delete all items older than this value [optional]
*/
public function cleanup(\DateTime $date = NULL) {
\F3::get('db')->exec('DELETE FROM items WHERE id IN (
SELECT items.id FROM items LEFT JOIN sources
ON items.source=sources.id WHERE sources.id IS NULL)');
\F3::get('db')->exec('DELETE FROM items USING items LEFT JOIN sources
ON items.source=sources.id WHERE sources.id IS NULL');
if ($date !== NULL)
\F3::get('db')->exec('DELETE FROM items WHERE starred=0 AND datetime<:date',
array(':date' => $date->format('Y-m-d').' 00:00:00'));
Expand Down
16 changes: 16 additions & 0 deletions daos/sqlite/Items.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,20 @@
*/
// class Items extends Database {
class Items extends \daos\mysql\Items {

/**
* cleanup orphaned and old items
*
* @return void
* @param DateTime $date date to delete all items older than this value [optional]
*/
public function cleanup(\DateTime $date = NULL) {
\F3::get('db')->exec('DELETE FROM items WHERE id IN (
SELECT items.id FROM items LEFT JOIN sources
ON items.source=sources.id WHERE sources.id IS NULL)');
if ($date !== NULL)
\F3::get('db')->exec('DELETE FROM items WHERE starred=0 AND datetime<:date',
array(':date' => $date->format('Y-m-d').' 00:00:00'));
}

}

0 comments on commit bf8b501

Please sign in to comment.