]> git.mxchange.org Git - friendica.git/blob - src/Model/ItemUser.php
rename rawContent() to content()
[friendica.git] / src / Model / ItemUser.php
1 <?php
2
3 namespace Friendica\Model;
4
5 use Exception;
6 use Friendica\Database\DBA;
7
8 /**
9  * Model for user specific operations of items
10  */
11 class ItemUser
12 {
13         /**
14          * Returns fields of the user for an item
15          *
16          * @param int   $id     The item id
17          * @param array $fields The fields, which should get returned
18          *
19          * @return array|bool
20          * @throws Exception In case of a DB-failure
21          */
22         public static function getUserForItemId($id, array $fields = [])
23         {
24                 $item = DBA::selectFirst('item', ['uid'], ['id' => $id]);
25                 if (empty($item)) {
26                         return false;
27                 }
28
29                 $user = DBA::selectFirst('user', $fields, ['uid' => $item['uid']]);
30                 if (!empty($user)) {
31                         return $user;
32                 } else {
33                         return false;
34                 }
35         }
36 }