Ensure *toArray returns an array
This commit is contained in:
parent
b684fffcb7
commit
a61ce4fed0
3 changed files with 7 additions and 11 deletions
|
@ -1512,16 +1512,18 @@ class Database
|
|||
public function toArray($stmt, $do_close = true)
|
||||
{
|
||||
if (is_bool($stmt)) {
|
||||
return $stmt;
|
||||
return [];
|
||||
}
|
||||
|
||||
$data = [];
|
||||
while ($row = $this->fetch($stmt)) {
|
||||
$data[] = $row;
|
||||
}
|
||||
|
||||
if ($do_close) {
|
||||
$this->close($stmt);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ class Attach extends BaseObject
|
|||
* @param array $conditions Array of fields for conditions
|
||||
* @param array $params Array of several parameters
|
||||
*
|
||||
* @return boolean|array
|
||||
* @return array
|
||||
*
|
||||
* @throws \Exception
|
||||
* @see \Friendica\Database\DBA::selectToArray
|
||||
|
@ -55,7 +55,7 @@ class Attach extends BaseObject
|
|||
$fields = self::getFields();
|
||||
}
|
||||
|
||||
$r = DBA::selectToArray('attach', $fields, $conditions, $params);
|
||||
return DBA::selectToArray('attach', $fields, $conditions, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -383,16 +383,10 @@ class Item extends BaseObject
|
|||
$result = self::select($fields, $condition, $params);
|
||||
|
||||
if (is_bool($result)) {
|
||||
return $result;
|
||||
return [];
|
||||
}
|
||||
|
||||
$data = [];
|
||||
while ($row = self::fetch($result)) {
|
||||
$data[] = $row;
|
||||
}
|
||||
DBA::close($result);
|
||||
|
||||
return $data;
|
||||
return DBA::toArray($result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue