Closed
Description
PHP Version
8.1
CodeIgniter4 Version
4.5.1
CodeIgniter4 Installation Method
Composer (using codeigniter4/appstarter
)
Which operating systems have you tested for this bug?
Windows
Which server did you use?
apache
Database
PostgreSQL 15
What happened?
insertBatch never not return false
Steps to Reproduce
DataBase
CREATE TABLE public.test (
id serial4 NOT NULL,
"name" varchar(22) NOT NULL
);
Controller
public function test2()
{
$db = \Config\Database::connect();
$toInsert[] = [
'name' => 'aaaa'
];
$toInsert[] = [
'name' => null
];
try {
$db->transBegin();
$query = $this->db->table('public.test');
if ($query->insertBatch($toInsert) === false) {
d($db->error());
d('Error from IF');
$db->transRollback();
}
else
{
$db->transCommit();
}
} catch (DatabaseException $th) {
d($th->getMessage());
d('Error from TRY');
$db->transRollback();
}
}
Expected Output
$query->insertBatch($toInsert) === false
Anything else?
Without the transaction, the code works correctly. With the transaction, there is an error. pg_affected_rows(): Argument #1 ($result) must be of type PgSql\Result, bool given