Use auto IDs; drop to PHP 8.2
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace FeedReaderCentral;
|
||||
|
||||
use BitBadger\PDODocument\{Custom, DocumentException, Parameters, Patch};
|
||||
use BitBadger\PDODocument\{Document, DocumentException, Patch};
|
||||
|
||||
/**
|
||||
* An item from a feed
|
||||
@@ -57,17 +57,14 @@ class Item
|
||||
*/
|
||||
public static function add(int $feedId, ParsedItem $parsed): void
|
||||
{
|
||||
Custom::nonQuery(<<<'SQL'
|
||||
INSERT INTO item (data)
|
||||
VALUES (json_set(:data, '$.id', (SELECT coalesce(max(data->>'id'), 0) + 1 FROM item)))
|
||||
SQL, Parameters::json(':data', new static(
|
||||
feed_id: $feedId,
|
||||
title: $parsed->title,
|
||||
item_guid: $parsed->guid,
|
||||
item_link: $parsed->link,
|
||||
published_on: $parsed->publishedOn,
|
||||
updated_on: $parsed->updatedOn,
|
||||
content: $parsed->content)));
|
||||
Document::insert(Table::ITEM, new static(
|
||||
feed_id: $feedId,
|
||||
title: $parsed->title,
|
||||
item_guid: $parsed->guid,
|
||||
item_link: $parsed->link,
|
||||
published_on: $parsed->publishedOn,
|
||||
updated_on: $parsed->updatedOn,
|
||||
content: $parsed->content));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user