First cut of item-with-feed and list impl
- Add strict types to all files - Convert many queries to document commands
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace FeedReaderCentral;
|
||||
|
||||
use BitBadger\Documents\DocumentException;
|
||||
use BitBadger\Documents\Field;
|
||||
use BitBadger\Documents\SQLite\Configuration;
|
||||
use BitBadger\Documents\SQLite\Custom;
|
||||
use BitBadger\Documents\SQLite\Definition;
|
||||
@@ -77,6 +79,59 @@ class Data
|
||||
$db->close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a JSON field comparison to find bookmarked items
|
||||
*
|
||||
* @param string $qualifier The table qualifier to include (optional; defaults to no qualifier)
|
||||
* @return Field A field that will find bookmarked items
|
||||
*/
|
||||
public static function bookmarkField(string $qualifier = ''): Field
|
||||
{
|
||||
$bookField = Field::EQ('is_bookmarked', 1, '@book');
|
||||
$bookField->qualifier = $qualifier;
|
||||
return $bookField;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a JSON field comparison to find items for a given feed
|
||||
*
|
||||
* @param int $feedId The ID of the feed for which items should be retrieved
|
||||
* @param string $qualifier The table qualifier to include (optional; defaults to no qualifier)
|
||||
* @return Field A field to find items for the give feed
|
||||
*/
|
||||
public static function feedField(int $feedId, string $qualifier = ''): Field
|
||||
{
|
||||
$feedField = Field::EQ(Configuration::idField(), $feedId, '@feed');
|
||||
$feedField->qualifier = $qualifier;
|
||||
return $feedField;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a JSON field comparison to find unread items
|
||||
*
|
||||
* @param string $qualifier The table qualifier to include (optional; defaults to no qualifier)
|
||||
* @return Field A field to find unread items
|
||||
*/
|
||||
public static function unreadField(string $qualifier = ''): Field
|
||||
{
|
||||
$readField = Field::EQ('is_read', 0, '@read');
|
||||
$readField->qualifier = $qualifier;
|
||||
return $readField;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a JSON field comparison to find items belonging to feeds to which the given user is subscribed
|
||||
*
|
||||
* @param string $qualifier The table qualifier to include (optional; defaults to no qualifier)
|
||||
* @return Field A field to find feeds belonging to the given user
|
||||
*/
|
||||
public static function userIdField(string $qualifier = ''): Field
|
||||
{
|
||||
$userField = Field::EQ('user_id', $_SESSION[Key::USER_ID], '@user');
|
||||
$userField->qualifier = $qualifier;
|
||||
return $userField;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse/format a date/time from a string
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user