mirror of
https://github.com/friendica/friendica
synced 2025-04-27 01:10:14 +00:00
Merge pull request #5261 from annando/and-again-abstraction
And again the item abstraction - and a fix for issue 5252
This commit is contained in:
commit
8a3cae686b
14 changed files with 129 additions and 127 deletions
|
@ -56,6 +56,40 @@ class Item extends BaseObject
|
|||
'author-id', 'author-link', 'owner-link', 'contact-uid',
|
||||
'signed_text', 'signature', 'signer'];
|
||||
|
||||
/**
|
||||
* @brief Fetch a single item row
|
||||
*
|
||||
* @param mixed $stmt statement object
|
||||
* @return array current row
|
||||
*/
|
||||
public static function fetch($stmt)
|
||||
{
|
||||
$row = dba::fetch($stmt);
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Fills an array with data from an item query
|
||||
*
|
||||
* @param object $stmt statement object
|
||||
* @return array Data array
|
||||
*/
|
||||
public static function inArray($stmt, $do_close = true) {
|
||||
if (is_bool($stmt)) {
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
$data = [];
|
||||
while ($row = self::fetch($stmt)) {
|
||||
$data[] = $row;
|
||||
}
|
||||
if ($do_close) {
|
||||
dba::close($stmt);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single record from the item table for a given user and returns it in an associative array
|
||||
*
|
||||
|
@ -118,7 +152,7 @@ class Item extends BaseObject
|
|||
if (is_bool($result)) {
|
||||
return $result;
|
||||
} else {
|
||||
$row = dba::fetch($result);
|
||||
$row = self::fetch($result);
|
||||
dba::close($result);
|
||||
return $row;
|
||||
}
|
||||
|
@ -225,7 +259,7 @@ class Item extends BaseObject
|
|||
if (is_bool($result)) {
|
||||
return $result;
|
||||
} else {
|
||||
$row = dba::fetch($result);
|
||||
$row = self::fetch($result);
|
||||
dba::close($result);
|
||||
return $row;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue