Все возвраты false изменены на пустой массив.

This commit is contained in:
Ivor Barhansky 2024-04-26 16:08:30 +03:00
parent 60ac124ea9
commit 3830c97ac2

View File

@ -53,11 +53,15 @@ class Db
/**
* @param string $query
* @param array $args
* @return false|array
* @return array
*/
public static function getRows(string $query, array $args = []): false|array
public static function getRows(string $query, array $args = []): array
{
return self::run($query, $args)->fetchAll();
$stmt = self::run($query, $args)->fetchAll();
if (!$stmt) {
return [];
}
return $stmt;
}
/**
@ -108,19 +112,23 @@ class Db
{
$result = self::getRow($query, $args);
if (!empty($result)) {
$result = array_shift($result);
return array_shift($result);
}
return $result;
return '';
}
/**
* @param string $query
* @param array $args
* @return mixed
* @return array
*/
public static function getRow(string $query, array $args = []): mixed
public static function getRow(string $query, array $args = []): array
{
return self::run($query, $args)->fetch();
$stmt = self::run($query, $args)->fetch();
if (!$stmt) {
return [];
}
return $stmt;
}
/**
@ -130,7 +138,11 @@ class Db
*/
public static function getColumn(string $query, array $args = []): array
{
return self::run($query, $args)->fetchAll(PDO::FETCH_COLUMN);
$stmt = self::run($query, $args)->fetchAll(PDO::FETCH_COLUMN);
if (!$stmt) {
return [];
}
return $stmt;
}
/**