-
-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathBatchCommand.php
More file actions
44 lines (36 loc) · 780 Bytes
/
BatchCommand.php
File metadata and controls
44 lines (36 loc) · 780 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
44
<?php
declare(strict_types=1);
namespace Yiisoft\Db\Command;
use Yiisoft\Db\Exception\Exception;
/**
* Object used as batch commands container
*/
final class BatchCommand
{
/**
* @param CommandInterface[] $commands Query statements for execution
*/
public function __construct(private readonly array $commands)
{
}
public function count(): int
{
return count($this->commands);
}
public function getCommands(): array
{
return $this->commands;
}
/**
* @throws \Throwable
* @throws Exception
*/
public function execute(): int
{
$total = 0;
foreach ($this->commands as $command) {
$total += $command->execute();
}
return $total;
}
}