PHP Modules Tutorials - Herong's Tutorial Examples
∟MySQLi Module - Accessing MySQL Server
∟mysqli_connect() and Other MySQL Functions
This section describes procedural functions provided by MySQLi module. mysql_connect() creates a connection to the specified MySQL server.
MySQLi module offers 2 interfaces: object-oriented interface and procedural interface.
The procedural interface provides almost identical functions as the original MySQL module,
except that MySQLi function names are prefixed with "mysqli." instead of "mysql_".
Here are some commonly used MySQLi functions:
- mysqli_connect() - Connects to a MySQL server, and returns a connection resource.
In most cases, you need to call it with 3 arguments like mysqli_connect($server, $username, $password).
$server specifies the network address of machine where the MySQL server is running.
$username specifies the user login name on the MySQL server.
$password specifies the password for the login name.
- mysqli_close() - Closes a MySQL connection resource. Usually, you call it with 1 parameter
like mysqli_close($connection), where $connection represents the connection resource to be closed.
- mysqli_get_server_info() - Returns a string of server information.
- mysqli_status() - Returns a string of server status.
- mysqli_query() - Sends a query to the server, and returns a result set resource.
For example, mysqli_query('SELECT * FROM MyTable WHERE ID = 10').
- mysqli_affected_rows() - Returns the number of effected rows of the given result set,
if the executed query is an INSERT or UPDATE statement.
- mysqli_num_rows() - Returns the number of rows of the given result set, if the
executed query is a SELECT statement.
- mysqli_fetch_array() - Fetches a row from a given result set, and returns the row
as an array with both numeric index, and column name map. It will return boolean false,
if there is no row left in the result set.
- mysqli_free_result() - Frees the given result set.
Table of Contents
About This Book
Introduction and Installation of PHP
Managing PHP Engine and Modules on macOS
Managing PHP Engine and Modules on CentOS
cURL Module - Client for URL
DOM Module - Parsing HTML Documents
GD Module - Manipulating Images and Pictures
►MySQLi Module - Accessing MySQL Server
MySQLi Module Configuration and Database Access
►mysqli_connect() and Other MySQL Functions
MySqlLoop.php - MySQL Functions Test
OpenSSL Module - Cryptography and SSL/TLS Toolkit
PCRE Module - Perl Compatible Regular Expressions
SOAP Module - Creating and Calling Web Services
SOAP Module - Server Functions and Examples
Zip Module - Managing ZIP Archive Files
References
Full Version in PDF/EPUB