2016-08-19 04:20:49 +02:00
|
|
|
<?php
|
|
|
|
|
2016-12-26 15:44:53 +01:00
|
|
|
namespace Miniflux\Model\ItemSearch;
|
2016-08-19 04:20:49 +02:00
|
|
|
|
|
|
|
use PicoDb\Database;
|
2016-12-26 15:44:53 +01:00
|
|
|
use Miniflux\Model\Feed;
|
|
|
|
use Miniflux\Model\Item;
|
2016-08-19 04:20:49 +02:00
|
|
|
|
2016-12-26 15:44:53 +01:00
|
|
|
function count_items($user_id, $text)
|
2016-08-19 04:20:49 +02:00
|
|
|
{
|
|
|
|
return Database::getInstance('db')
|
2016-12-26 15:44:53 +01:00
|
|
|
->table(Item\TABLE)
|
|
|
|
->eq('user_id', $user_id)
|
|
|
|
->neq('status', Item\STATUS_REMOVED)
|
2016-08-19 04:20:49 +02:00
|
|
|
->ilike('title', '%' . $text . '%')
|
|
|
|
->count();
|
|
|
|
}
|
|
|
|
|
2016-12-26 15:44:53 +01:00
|
|
|
function get_all_items($user_id, $text, $offset = null, $limit = null)
|
2016-08-19 04:20:49 +02:00
|
|
|
{
|
|
|
|
return Database::getInstance('db')
|
2016-12-26 15:44:53 +01:00
|
|
|
->table(Item\TABLE)
|
2016-08-19 04:20:49 +02:00
|
|
|
->columns(
|
|
|
|
'items.id',
|
|
|
|
'items.title',
|
|
|
|
'items.updated',
|
|
|
|
'items.url',
|
2016-12-26 15:44:53 +01:00
|
|
|
'items.enclosure_url',
|
2016-08-19 04:20:49 +02:00
|
|
|
'items.enclosure_type',
|
|
|
|
'items.bookmark',
|
|
|
|
'items.feed_id',
|
|
|
|
'items.status',
|
|
|
|
'items.content',
|
|
|
|
'items.language',
|
2016-12-26 15:44:53 +01:00
|
|
|
'items.rtl',
|
2016-08-19 04:20:49 +02:00
|
|
|
'items.author',
|
|
|
|
'feeds.site_url',
|
2016-12-26 15:44:53 +01:00
|
|
|
'feeds.title AS feed_title'
|
2016-08-19 04:20:49 +02:00
|
|
|
)
|
2016-12-26 15:44:53 +01:00
|
|
|
->join(Feed\TABLE, 'id', 'feed_id')
|
|
|
|
->eq('items.user_id', $user_id)
|
|
|
|
->neq('items.status', Item\STATUS_REMOVED)
|
2016-08-19 04:20:49 +02:00
|
|
|
->ilike('items.title', '%' . $text . '%')
|
2016-12-26 15:44:53 +01:00
|
|
|
->orderBy('items.updated', 'desc')
|
2016-08-19 04:20:49 +02:00
|
|
|
->offset($offset)
|
|
|
|
->limit($limit)
|
|
|
|
->findAll();
|
|
|
|
}
|