cs.punk Posted September 4, 2009 Share Posted September 4, 2009 Taken from the php manual of mysqli_fetch_assoc <?php $mysqli = new mysqli("localhost", "my_user", "my_password", "world"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $query = "SELECT Name, CountryCode FROM City ORDER by ID DESC LIMIT 50,5"; if ($result = $mysqli->query($query)) { /* fetch associative array */ while ($row = $result->fetch_assoc()) { printf ("%s (%s)\n", $row["Name"], $row["CountryCode"]); } /* free result set */ $result->close(); } /* close connection */ $mysqli->close(); ?> There is no class defined of 'mysqli'? Is this a built in one? And I noticed if ($result = $mysqli->query($query)) { // And later on /* free result set */ $result->close(); Where was $result made an instance of a class? Quote Link to comment Share on other sites More sharing options...
rhodesa Posted September 4, 2009 Share Posted September 4, 2009 mysqli classes are available if the module is enabled: http://us.php.net/manual/en/mysqli.installation.php The method query() in the mysqli object just returns an object. The code inside query() creates a MySQLi Result Instance and then just returns it 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.