-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: insertBatch not return false #9362
Comments
A couple of things:
Anyway, I was able to recreate the problem. |
In this way, it is fine. Output 'Error from TRY' With this $db->transStatus() === false ? hym not working ?
|
Sorry, but I'm not sure what you're asking me. Here are the cases when you use transactions. When try {
$db->transException(true)->transStart();
$query = $db->table('public.test');
$query->insertBatch($toInsert);
$db->transComplete();
} catch (DatabaseException $th) {
d('Error from TRY');
} If something goes wrong with your insert, the query will be rolled back automatically and an exception will be thrown. The second case is when $db->transStart();
$query = $db->table('public.test');
$query->insertBatch($toInsert);
$db->transComplete();
if ($db->transStatus() === false) {
d('Error from insert');
} In this case, we need to check whether the transaction was unsuccessful to display the error. |
Please check if #9363 fixes your problem. |
Yes, this change works correctly - thank you. |
Thank you @okatse |
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
Controller
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
The text was updated successfully, but these errors were encountered: