suivi index du row
This commit is contained in:
parent
22c8067c8f
commit
4c138708ed
|
@ -33,6 +33,7 @@ abstract class AbstractBuilder extends TempStream implements IBuilder {
|
||||||
$rows = $params["rows"] ?? null;
|
$rows = $params["rows"] ?? null;
|
||||||
if (is_callable($rows)) $rows = $rows();
|
if (is_callable($rows)) $rows = $rows();
|
||||||
$this->rows = $rows;
|
$this->rows = $rows;
|
||||||
|
$this->index = 0;
|
||||||
$cookFunc = $params["cook_func"] ?? null;
|
$cookFunc = $params["cook_func"] ?? null;
|
||||||
$cookCtx = $cookArgs = null;
|
$cookCtx = $cookArgs = null;
|
||||||
if ($cookFunc !== null) {
|
if ($cookFunc !== null) {
|
||||||
|
@ -55,6 +56,8 @@ abstract class AbstractBuilder extends TempStream implements IBuilder {
|
||||||
|
|
||||||
protected ?iterable $rows;
|
protected ?iterable $rows;
|
||||||
|
|
||||||
|
protected int $index;
|
||||||
|
|
||||||
protected ?string $output;
|
protected ?string $output;
|
||||||
|
|
||||||
protected ?array $cookCtx;
|
protected ?array $cookCtx;
|
||||||
|
@ -89,14 +92,14 @@ abstract class AbstractBuilder extends TempStream implements IBuilder {
|
||||||
$row = nur_func::_call($this->cookCtx, $args);
|
$row = nur_func::_call($this->cookCtx, $args);
|
||||||
}
|
}
|
||||||
if ($row !== null) {
|
if ($row !== null) {
|
||||||
foreach ($row as &$value) {
|
foreach ($row as &$col) {
|
||||||
# formatter les dates
|
# formatter les dates
|
||||||
if ($value instanceof DateTime) {
|
if ($col instanceof DateTime) {
|
||||||
$value = $value->format();
|
$col = $col->format();
|
||||||
} elseif ($value instanceof DateTimeInterface) {
|
} elseif ($col instanceof DateTimeInterface) {
|
||||||
$value = DateTime::with($value)->format();
|
$col = DateTime::with($col)->format();
|
||||||
}
|
}
|
||||||
}; unset($value);
|
}; unset($col);
|
||||||
}
|
}
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
@ -106,6 +109,7 @@ abstract class AbstractBuilder extends TempStream implements IBuilder {
|
||||||
if ($row === null) return;
|
if ($row === null) return;
|
||||||
$this->writeHeaders(array_keys($row));
|
$this->writeHeaders(array_keys($row));
|
||||||
$this->_write($row, $colsStyle, $rowStyle);
|
$this->_write($row, $colsStyle, $rowStyle);
|
||||||
|
$this->index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeAll(?iterable $rows=null, ?array $rowStyle=null): void {
|
function writeAll(?iterable $rows=null, ?array $rowStyle=null): void {
|
||||||
|
|
Loading…
Reference in New Issue