major update
This commit is contained in:
37
lib/Repository/Search/SearchQueryRepository.php
Normal file
37
lib/Repository/Search/SearchQueryRepository.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Search;
|
||||
|
||||
use MintyPHP\DB;
|
||||
|
||||
class SearchQueryRepository
|
||||
{
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user