Skip to content

Commit 17170b4

Browse files
committed
- Allow Traversable-Objects for Kir\MySQL\Builder\RunnableInsert::insertRows($rows)
1 parent 2b48055 commit 17170b4

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Builder/RunnableInsert.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
<?php
22
namespace Kir\MySQL\Builder;
33

4+
use BadMethodCallException;
5+
use Traversable;
6+
47
class RunnableInsert extends Insert {
58
/**
6-
* @param array $rows
9+
* @param array|Traversable $rows
710
* @return int[] Insert IDs
811
*/
9-
public function insertRows(array $rows) {
12+
public function insertRows($rows) {
13+
if(!(is_array($rows) || $rows instanceof Traversable)) {
14+
throw new BadMethodCallException('Expected $rows to by an array or an instance of \\Traversable');
15+
}
1016
$result = [];
1117
$query = $this->__toString();
1218
$stmt = $this->db()->prepare($query);

0 commit comments

Comments
 (0)