X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FPost.php;h=2baa76b5be676a69ec16434de78b7e3a8905f8a6;hb=7676aa790867d9d37f0996483140f505408fd665;hp=635a84efd6fbc7ac4625af896e170ddb5dc2f571;hpb=d05ee962f95042420447a1e6edc22216c9ad93f4;p=friendica.git diff --git a/src/Model/Post.php b/src/Model/Post.php index 635a84efd6..2baa76b5be 100644 --- a/src/Model/Post.php +++ b/src/Model/Post.php @@ -102,26 +102,25 @@ class Post } /** - * Fills an array with data from an post query + * Fills an array with data from a post query * - * @param object $stmt statement object - * @param bool $do_close + * @param object|bool $stmt Return value from Database->select * @return array Data array - * @todo Find proper type-hint for $stmt and maybe avoid boolean + * @throws \Exception */ - public static function toArray($stmt, bool $do_close = true) + public static function toArray($stmt): array { if (is_bool($stmt)) { - return $stmt; + return []; } $data = []; while ($row = self::fetch($stmt)) { $data[] = $row; } - if ($do_close) { - DBA::close($stmt); - } + + DBA::close($stmt); + return $data; } @@ -375,6 +374,21 @@ class Post return self::selectView('post-thread-user-view', $selected, $condition, $params); } + /** + * Select rows from the post-thread-view view + * + * @param array $selected Array of selected fields, empty for all + * @param array $condition Array of fields for condition + * @param array $params Array of several parameters + * + * @return boolean|object + * @throws \Exception + */ + public static function selectPostThread(array $selected = [], array $condition = [], array $params = []) + { + return self::selectView('post-thread-view', $selected, $condition, $params); + } + /** * Select rows from the given view for a given user *