Remove direct PDO handling
This commit is contained in:
@@ -1,11 +1,7 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
use BitBadger\PDODocument\Configuration;
|
||||
use BitBadger\PDODocument\DocumentException;
|
||||
use BitBadger\PDODocument\Find;
|
||||
use FeedReaderCentral\Feed;
|
||||
use FeedReaderCentral\Table;
|
||||
use FeedReaderCentral\User;
|
||||
use BitBadger\PDODocument\{DocumentException, Find};
|
||||
use FeedReaderCentral\{Feed, Table, User};
|
||||
|
||||
require __DIR__ . '/../cli-start.php';
|
||||
|
||||
@@ -36,17 +32,10 @@ function display_help(): never
|
||||
|
||||
function refresh_all(): void
|
||||
{
|
||||
try {
|
||||
$pdo = Configuration::dbConn();
|
||||
} catch (DocumentException $ex) {
|
||||
printfn("ERR: Cannot obtain a connection to the database\n $ex");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$users = [];
|
||||
iterator_apply(Feed::retrieveAll()->items(), function (Feed $feed) use ($pdo, &$users) {
|
||||
$result = Feed::refreshFeed($feed->id, $feed->url, $pdo);
|
||||
iterator_apply(Feed::retrieveAll()->items(), function (Feed $feed) use (&$users) {
|
||||
$result = Feed::refreshFeed($feed->id, $feed->url);
|
||||
$userKey = "$feed->user_id";
|
||||
if (!key_exists($userKey, $users)) $users[$userKey] = Find::byId(Table::USER, $feed->user_id, User::class);
|
||||
if (array_key_exists('error', $result)) {
|
||||
|
||||
Reference in New Issue
Block a user