Standards and a new function to fetch content

This commit is contained in:
Michael 2018-06-21 15:14:01 +00:00
parent 5743bb0dae
commit d643e00d33
9 changed files with 59 additions and 25 deletions

View file

@ -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;
}