|
|
@@ -7,7 +7,6 @@ class FreshRSS_EntryDAOSQLite extends FreshRSS_EntryDAO {
|
|
|
}
|
|
|
|
|
|
protected function autoUpdateDb($errorInfo) {
|
|
|
- Minz_Log::error('FreshRSS_EntryDAO::autoUpdateDb error: ' . print_r($errorInfo, true));
|
|
|
if ($tableInfo = $this->bd->query("SELECT sql FROM sqlite_master where name='entrytmp'")) {
|
|
|
$showCreate = $tableInfo->fetchColumn();
|
|
|
if (stripos($showCreate, 'entrytmp') === false) {
|
|
|
@@ -27,63 +26,28 @@ class FreshRSS_EntryDAOSQLite extends FreshRSS_EntryDAO {
|
|
|
|
|
|
public function commitNewEntries() {
|
|
|
$sql = '
|
|
|
- CREATE TEMP TABLE `tmp` AS
|
|
|
- SELECT
|
|
|
- id,
|
|
|
- guid,
|
|
|
- title,
|
|
|
- author,
|
|
|
- content,
|
|
|
- link,
|
|
|
- date,
|
|
|
- `lastSeen`,
|
|
|
- hash, is_read,
|
|
|
- is_favorite,
|
|
|
- id_feed,
|
|
|
- tags
|
|
|
- FROM `' . $this->prefix . 'entrytmp`
|
|
|
- ORDER BY date;
|
|
|
- INSERT OR IGNORE INTO `' . $this->prefix . 'entry`
|
|
|
- (
|
|
|
- id,
|
|
|
- guid,
|
|
|
- title,
|
|
|
- author,
|
|
|
- content,
|
|
|
- link,
|
|
|
- date,
|
|
|
- `lastSeen`,
|
|
|
- hash,
|
|
|
- is_read,
|
|
|
- is_favorite,
|
|
|
- id_feed,
|
|
|
- tags
|
|
|
- )
|
|
|
- SELECT rowid + (SELECT MAX(id) - COUNT(*) FROM `tmp`) AS
|
|
|
- id,
|
|
|
- guid,
|
|
|
- title,
|
|
|
- author,
|
|
|
- content,
|
|
|
- link,
|
|
|
- date,
|
|
|
- `lastSeen`,
|
|
|
- hash,
|
|
|
- is_read,
|
|
|
- is_favorite,
|
|
|
- id_feed,
|
|
|
- tags
|
|
|
- FROM `tmp`
|
|
|
- ORDER BY date;
|
|
|
- DELETE FROM `' . $this->prefix . 'entrytmp`
|
|
|
- WHERE id <= (SELECT MAX(id)
|
|
|
- FROM `tmp`);
|
|
|
- DROP TABLE `tmp`;';
|
|
|
+DROP TABLE IF EXISTS `tmp`;
|
|
|
+CREATE TEMP TABLE `tmp` AS
|
|
|
+ SELECT id, guid, title, author, content, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags
|
|
|
+ FROM `' . $this->prefix . 'entrytmp`
|
|
|
+ ORDER BY date;
|
|
|
+INSERT OR IGNORE INTO `' . $this->prefix . 'entry`
|
|
|
+ (id, guid, title, author, content, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags)
|
|
|
+ SELECT rowid + (SELECT MAX(id) - COUNT(*) FROM `tmp`) AS id,
|
|
|
+ guid, title, author, content, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags
|
|
|
+ FROM `tmp`
|
|
|
+ ORDER BY date;
|
|
|
+DELETE FROM `' . $this->prefix . 'entrytmp` WHERE id <= (SELECT MAX(id) FROM `tmp`);
|
|
|
+DROP TABLE IF EXISTS `tmp`;
|
|
|
+';
|
|
|
$hadTransaction = $this->bd->inTransaction();
|
|
|
if (!$hadTransaction) {
|
|
|
$this->bd->beginTransaction();
|
|
|
}
|
|
|
$result = $this->bd->exec($sql) !== false;
|
|
|
+ if (!$result) {
|
|
|
+ Minz_Log::error('SQL error commitNewEntries: ' . json_encode($this->bd->errorInfo()));
|
|
|
+ }
|
|
|
if (!$hadTransaction) {
|
|
|
$this->bd->commit();
|
|
|
}
|