Created
May 16, 2017 18:51
-
-
Save mnewt/999237d5c2b0cfdd4af1418b84bd9dc6 to your computer and use it in GitHub Desktop.
Revisions
-
mnewt created this gist
May 16, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ #!/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);