miniflux-legacy/app/models/search.php

49 lines
1.3 KiB
PHP
Raw Normal View History

2016-08-19 04:20:49 +02:00
<?php
namespace Miniflux\Model\ItemSearch;
2016-08-19 04:20:49 +02:00
use PicoDb\Database;
use Miniflux\Model\Feed;
use Miniflux\Model\Item;
2016-08-19 04:20:49 +02:00
function count_items($user_id, $text)
2016-08-19 04:20:49 +02:00
{
return Database::getInstance('db')
->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();
}
function get_all_items($user_id, $text, $offset = null, $limit = null)
2016-08-19 04:20:49 +02:00
{
return Database::getInstance('db')
->table(Item\TABLE)
2016-08-19 04:20:49 +02:00
->columns(
'items.id',
'items.title',
'items.updated',
'items.url',
'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',
'items.rtl',
2016-08-19 04:20:49 +02:00
'items.author',
'feeds.site_url',
'feeds.title AS feed_title'
2016-08-19 04:20:49 +02: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 . '%')
->orderBy('items.updated', 'desc')
2016-08-19 04:20:49 +02:00
->offset($offset)
->limit($limit)
->findAll();
}