MySQLi Module and Configuration

This section describes the MySQLi module and its configurations.

What Is MySQLi Module? - MySQLi (MySQL Improved) Module, also called MySQLi Extension, allows you to access the functionality provided by MySQL database servers. MySQLi Module was introduced in PHP 5 and is replacing the original MySQL module.

Note that MySQLi module is not communicating directly with the MySQL server. It uses the mysqlnd (MySQL Native Driver) to the MySQL server

MySQLi module and mysqlnd driver are included in most PHP distribution packages. They are loaded automatically in the PHP environment.

But in some cases, you may need to enable MySQLi module explicitly in the php.ini configuration file, using one of the following settings, depending on which version of PHP you are using.

extension=mysqli
extension=mysqli.so
extension=php_mysqli.dll

On Windows systems, you may need to add \php\ext to the PATH system environment variable, because php_mysqli.dll is located in the \php\ext directory.

Here are the MySQL related modules loaded in the PHP environment on my macOS computer:

herong$ php -m

...
mysql
mysqli
mysqlnd
pdo_mysql

MySQLi module supports a number of configuration settings for you to control its default behavior. For example, here is what I have on my macOS computer:

herong$ php -i

...
mysqli

MysqlI Support => enabled
Client API library version => mysqlnd 5.0.11-dev - 20120503 - $Id$
Active Persistent Links => 0
Inactive Persistent Links => 0
Active Links => 0

Directive => Local Value => Master Value
mysqli.allow_local_infile => On => On
mysqli.allow_persistent => On => On
mysqli.default_host => 127.0.0.1 => 127.0.0.1
mysqli.default_port => 3306 => 3306
mysqli.default_pw => TopSecret => TopSecret
mysqli.default_socket => /var/mysql/mysql.sock => /var/mysql/mysql.sock
mysqli.default_user => herong => herong
mysqli.max_links => Unlimited => Unlimited
mysqli.max_persistent => Unlimited => Unlimited
mysqli.reconnect => Off => Off
mysqli.rollback_on_cached_plink => Off => Off

PHP configuration settings are specified in the PHP.ini, which is located at /etc/php.ini on my macOS computer.

Table of Contents

 About This Book

 Introduction and Installation of PHP

 Managing PHP Environment and Modules on macOS

 Managing PHP Environment and Modules on CentOS

 Configuration and Modules

 cURL Module - Client for URL

 DOM Module - Parsing HTML Documents

 GD Module - Manipulating Images and Pictures

MySQLi Module - Accessing MySQL Server

MySQLi Module and Configuration

 mysqli-hello.php - Test MySQLi Module

 mysqli_connect() - Open MySQL Connection

 mysqli_query() - Run SQL Queries

 mysqli_affected_rows() - Count Affected Rows

 mysqli_insert_id() - ID from AUTO_INCREMENT

 mysqli_fetch_array() - Fetch Row from Query Result

 mysqli_fetch_fields() - Fetch Field Information

 Escape Escape Characters - \\\\ for \\

 Summary of Basic MySQLi Functions

 MySQLi Object-Oriented Programming

 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

 Index

 Full Version in PDF/EPUB