-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathSqlQueryRow.php
More file actions
43 lines (33 loc) · 852 Bytes
/
SqlQueryRow.php
File metadata and controls
43 lines (33 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
declare(strict_types=1);
namespace Ray\Query;
use Aura\Sql\ExtendedPdoInterface;
use function array_pop;
use function assert;
use function count;
use function is_iterable;
/** @psalm-api */
class SqlQueryRow implements RowInterface
{
/** @var ExtendedPdoInterface */
private $pdo;
/** @var string */
private $sql;
public function __construct(ExtendedPdoInterface $pdo, string $sql)
{
$this->pdo = $pdo;
$this->sql = $sql;
}
/** @param array<string, mixed> ...$queries */
public function __invoke(array ...$queries): iterable
{
$query = $queries[0];
$item = $this->pdo->fetchAssoc($this->sql, $query);
if (! count($item)) {
return [];
}
$list = array_pop($item);
assert(is_iterable($list));
return $list;
}
}