Files
Testbed/app/Database/Db2/Db2Processor.php
T
2026-11-11 09:57:07 +00:00

35 lines
856 B
PHP

<?php
namespace App\Database\Db2;
use Illuminate\Database\Query\Processors\Processor;
class Db2Processor extends Processor
{
public function processInsertGetId($query, $sql, $values, $sequence = null)
{
$query->getConnection()->insert($sql, $values);
$result = $query->getConnection()->selectOne(
'SELECT IDENTITY_VAL_LOCAL() AS ID FROM SYSIBM.SYSDUMMY1',
[],
false
);
if ($result === null) {
throw new \RuntimeException(
'Db2 did not return a generated identity value.'
);
}
$id = $result->ID ?? $result->id ?? null;
if ($id === null) {
throw new \RuntimeException(
'Db2 identity value was NULL.'
);
}
return is_numeric($id) ? (int) $id : $id;
}
}