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

Commit

Permalink
Merge pull request fossar#299 from seanrand/nested-subquery-fix
Browse files Browse the repository at this point in the history
Fix update.php failing with MySQL (fossar#298)
  • Loading branch information
SSilence committed Apr 28, 2013
2 parents 46cb4e7 + bf8b501 commit 18166f1
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 18166f1

Please sign in to comment.