Oracle 5.0 Reference Manual page 2568

Table of Contents

Advertisement

At the code level,
mysqlnd
In C you use a
struct
Struct members pointing to functions represent methods.
Unlike with other languages such as C++ or Java, there are no fixed rules on inheritance in the C
object oriented paradigm. However, there are some conventions that need to be followed that will be
discussed later.
The PHP Life Cycle
When considering the PHP life cycle there are two basic cycles:
• PHP engine startup and shutdown cycle
• Request cycle
When the PHP engine starts up it will call the module initialization (MINIT) function of each registered
extension. This allows each module to setup variables and allocate resources that will exist for the
lifetime of the PHP engine process. When the PHP engine shuts down it will call the module shutdown
(MSHUTDOWN) function of each extension.
During the lifetime of the PHP engine it will receive a number of requests. Each request constitutes
another life cycle. On each request the PHP engine will call the request initialization function of each
extension. The extension can perform any variable setup and resource allocation required for request
processing. As the request cycle ends the engine calls the request shutdown (RSHUTDOWN) function
of each extension so the extension can perform any cleanup required.
How a plugin works
A
plugin works by intercepting calls made to
mysqlnd
This is achieved by obtaining the
function table, which calls the functions of the plugin as required.
The following code shows how the
/* a place to store original function table */
struct st_mysqlnd_conn_methods org_methods;
void minit_register_hooks(TSRMLS_D) {
/* active function table */
struct st_mysqlnd_conn_methods * current_methods
= mysqlnd_conn_get_methods();
/* backup original function table */
memcpy(&org_methods, current_methods,
sizeof(struct st_mysqlnd_conn_methods);
/* install new methods */
current_methods->query = MYSQLND_METHOD(my_conn_class, query);
}
Connection function table manipulations must be done during Module Initialization (MINIT). The
function table is a global shared resource. In an multi-threaded environment, with a TSRM build, the
manipulation of a global shared resource during the request processing will almost certainly result in
conflicts.
Note
Do not use any fixed-size logic when manipulating the
new methods may be added at the end of the function table. The function table
may change at any time in the future.
MySQL Native Driver (Mysqlnd)
uses a C pattern for implementing object orientation.
to represent an object. Members of the struct represent object properties.
function table, backing it up, and replacing it by a custom
mysqlnd
function table is replaced:
mysqlnd
2548
by extensions that use mysqlnd.
mysqlnd
mysqlnd
function table:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents