Files
breadcrumb-the-shire/lib/Repository/Search/SearchQueryRepository.php
2026-03-05 08:26:51 +01:00

38 lines
763 B
PHP

<?php
namespace MintyPHP\Repository\Search;
use MintyPHP\DB;
class SearchQueryRepository implements SearchQueryRepositoryInterface
{
/**
* @param array<int, mixed> $params
* @return array<int, mixed>
*/
public function selectRows(string $sql, array $params = []): array
{
if (trim($sql) === '') {
return [];
}
$rows = DB::select($sql, ...$params);
return is_array($rows) ? $rows : [];
}
/**
* @param array<int, mixed> $params
*/
public function selectCount(string $sql, array $params = []): int
{
if (trim($sql) === '') {
return 0;
}
$value = DB::selectValue($sql, ...$params);
return (int) ($value ?? 0);
}
}