Jump to content

Are the php classes built in?


cs.punk

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/173140-are-the-php-classes-built-in/
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.