Skip to content

Instantly share code, notes, and snippets.

@mnewt
Created May 16, 2017 18:51
Show Gist options
  • Save mnewt/999237d5c2b0cfdd4af1418b84bd9dc6 to your computer and use it in GitHub Desktop.
Save mnewt/999237d5c2b0cfdd4af1418b84bd9dc6 to your computer and use it in GitHub Desktop.
Search for matching miniflux items and mark them as read
#!/usr/bin/env php
<?php
require __DIR__.'/miniflux/app/common.php';
use PicoDb\Database;
use Miniflux\Model\Item;
if (php_sapi_name() !== 'cli') {
die('This script can run only from the command line.'.PHP_EOL);
}
if ($argc !== 3) {
die('Usage: '.$argv[0].' <USER> <STRING>'.PHP_EOL);
}
$user_id = (int)$argv[1];
$string = $argv[2];
function change_matching_items_status($user_id, $string, $new_status)
{
if (! in_array($new_status, array(Item\STATUS_READ, Item\STATUS_UNREAD, Item\STATUS_REMOVED))) {
return false;
}
return Database::getInstance('db')
->table(Item\TABLE)
->eq('user_id', $user_id)
->like('title', '%'.$string.'%')
->update(array('status' => $new_status));
}
change_matching_items_status($user_id, $string, Item\STATUS_READ);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment