Oracle 5.0 Reference Manual page 2574

Table of Contents

Advertisement

sizeof(struct st_mysqlnd_conn_methods));
conn_m->query = MYSQLND_METHOD(mysqlnd_plugin_conn, query);
conn_m->connect = MYSQLND_METHOD(mysqlnd_plugin_conn, connect);
}
/* my_mysqlnd_plugin.c */
enum_func_status MYSQLND_METHOD(mysqlnd_plugin_conn, query)(/* ... */) {
/* ... */
}
enum_func_status MYSQLND_METHOD(mysqlnd_plugin_conn, connect)(/* ... */) {
/* ... */
}
Task analysis: from C to userspace
class proxy extends mysqlnd_plugin_connection {
public function connect($host, ...) { .. }
}
mysqlnd_plugin_set_conn_proxy(new proxy());
Process:
1. PHP: user registers plugin callback
2. PHP: user calls any PHP MySQL API to connect to MySQL
3. C: ext/*mysql* calls mysqlnd method
4. C: mysqlnd ends up in ext/mysqlnd_plugin
5. C: ext/mysqlnd_plugin
a. Calls userspace callback
b. Or original
mysqlnd
You need to carry out the following:
1. Write a class "mysqlnd_plugin_connection" in C
2. Accept and register proxy object through "mysqlnd_plugin_set_conn_proxy()"
3. Call userspace proxy methods from C (optimization - zend_interfaces.h)
Userspace object methods can either be called using
a level closer to the Zend Engine and use zend_call_method().
Optimization: calling methods from C using zend_call_method
The following code snippet shows the prototype for the
zend_interfaces.h.
ZEND_API zval* zend_call_method(
zval **object_pp, zend_class_entry *obj_ce,
zend_function **fn_proxy, char *function_name,
int function_name_len, zval **retval_ptr_ptr,
int param_count, zval* arg1, zval* arg2 TSRMLS_DC
);
Zend API supports only two arguments. You may need more, for example:
MySQL Native Driver (Mysqlnd)
method, if userspace callback not set
2554
call_user_function()
zend_call_method
or you can operate at
function, taken from

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents