ds111 Posted August 5, 2009 Share Posted August 5, 2009 Hello I have the following code.. <?php $mysqli = db_connect ($dbn); // <-- This returns mysqli dbconnection link $query = "SELECT user_id, role, test FROM users WHERE uid=? AND id=?"; $stmt = $mysqli->stmt_init (); if ($stmt->prepare ($query)) { $stmt->bind_param ("ii", $uid, $id); $stmt->execute (); $stmt->bind_result ($this->user_id, $this->role, $this->test); $stmt->fetch (); $stmt->close (); $mysqli->close (); return NULL; } I am using MYSQLi as you can see. I have a question: Is $mysqli->close() the same as $stmt->close() ? Do I need those two lines of code or by closing $stmt I also close $mysqli since its in the same class? Thank you for any answers. Quote Link to comment Share on other sites More sharing options...
ds111 Posted August 5, 2009 Author Share Posted August 5, 2009 Anyone Know? Quote Link to comment Share on other sites More sharing options...
ldougherty Posted August 5, 2009 Share Posted August 5, 2009 http://php.oregonstate.edu/manual/en/mysqli.close.php mysqli::close Closes a previously opened database connection. http://us.php.net/manual/en/mysqli-stmt.close.php mysqli_stmt::close Closes a prepared statement. Quote Link to comment Share on other sites More sharing options...
ds111 Posted August 6, 2009 Author Share Posted August 6, 2009 Does this work when you are instantiating the Mysqli class as well? because it looks like you call mysqli_stmt_close() only when you do not use the OOP style. Since $stmt is a "shortcut" to $mysqli->stmt_init(); then wouldn't $stmt->close() be the same thing as: $mysqli->stmt_init()->close(); ? What does stmt_init() return? I thought it returns $this so that you can then call another function of the Mysqli class...? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.