Welcome Guest, Not a member yet? Register   Sign In
transStatus error
#3

(06-16-2025, 11:27 AM)okatse Wrote: Hi
What am I doing wrong?

PHP Code:
        $edb = \Config\Database::connect();
        $res $edb->prepare(function ($edb) {
            $query "select * from test limit :limit";
            return $edb->query($query);
        });
        $edb->transStart();
        $results $res
            
->execute(['limit' => 1])
            ->getResultArray();
        $edb->transComplete(); 
Cannot access protected property CodeIgniter\Database\Postgre\Connection::$transStatus
\Database\BasePreparedQuery.php at line 141

For this:


I also had problems with CodeIgniter 4 when combining prepare() + PostgreSQL + transactions.

Instead of using prepare() use parameterized queries directly with query() or table() something like:

Code:
$edb = \Config\Database::connect();
$edb->transStart();

$query = "SELECT * FROM test LIMIT ?";
$results = $edb->query($query, [1])->getResultArray();

$edb->transComplete();

? is used for positional binding — this works well in PostgreSQL and avoids the internal issue with $transStatus

I have not tested above but hope that may help.
Reply


Messages In This Thread
transStatus error - by okatse - 06-16-2025, 11:27 AM
RE: transStatus error - by michalsn - 06-16-2025, 01:15 PM
RE: transStatus error - by spreaderman - 06-16-2025, 08:41 PM
RE: transStatus error - by michalsn - 06-16-2025, 10:31 PM
RE: transStatus error - by okatse - 06-16-2025, 11:14 PM



Theme © iAndrew 2016 - Forum software by © MyBB