Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQLi - property access is not allowed yet [duplicate]

Im' getting this warning "property access is not allowed yet" when trying to close mysqli connection. WHY?

$mysqli = new mysqli ( $database ["dbUri"], $database ["dbUserName"], $database ["dbPassword"], $database ["dbSchema"], $database ["dbPort"] );
$mysqli->autocommit(FALSE);
$con = $mysqli;
$rowsAffected = /* completes insert using $con */;
if ($rowsAffected==0) {
    throw new Exception("Insert of new record failed");
}
$insertId = $con->insert_id;
$con->commit();
$con->close();

BTW, the insert is successful and I have the correct value in $insertId. Commit works well too, but it's the close that triggers the warning.

I hid the code in /* completes insert using $con */ section as it is long and irrelevant (the sql works). So unless you think it is relevant I only included the rest.

I looked at similar questions but other posts refer to the connection not being established. However, my connection works. PLEASE see the point about "insert is successful".

like image 608
NEW2WEB Avatar asked Dec 20 '22 06:12

NEW2WEB


1 Answers

As far as my analysis of this intermittent problem has concluded (at least in my case), this is some kind of bug in either the mysqli extension or the PHP debugger (XDebug), since it only happens when I breakpoint/single-step the program, but not when simply running the same code without breakpointing/single-stepping any code before the page rendering has completed.

Does it still happen for you if you don't breakpoint or single-step any code before the page rendering is complete?

like image 162
QuestionOverflow Avatar answered Jan 05 '23 11:01

QuestionOverflow