Oracle 5.0 Reference Manual page 2569

Table of Contents

Advertisement

Calling parent methods
If the original function table entries are backed up, it is still possible to call the original function table
entries - the parent methods.
In some cases, such as for Connection::stmt_init(), it is vital to call the parent method prior to
any other activity in the derived method.
MYSQLND_METHOD(my_conn_class, query)(MYSQLND *conn,
const char *query, unsigned int query_len TSRMLS_DC) {
php_printf("my_conn_class::query(query = %s)\n", query);
query = "SELECT 'query rewritten' FROM DUAL";
query_len = strlen(query);
return org_methods.query(conn, query, query_len); /* return with call to parent */
}
Extending properties
A
object is represented by a C struct. It is not possible to add a member to a C struct at run
mysqlnd
time. Users of
mysqlnd
Arbitrary data (properties) can be added to a
mysqlnd_plugin_get_plugin_<object>_data()
reserves space at the end of the object to hold a
space for one
void *
The following table shows how to calculate the position of the pointer for a specific plugin:
Table 20.67. Pointer calculations for mysqlnd
Memory address
0
n
n + (m x sizeof(void*))
If you plan to subclass any of the
mind!
The following code shows extending properties:
/* any data we want to associate */
typedef struct my_conn_properties {
unsigned long query_counter;
} MY_CONN_PROPERTIES;
/* plugin id */
unsigned int my_plugin_id;
void minit_register_hooks(TSRMLS_D) {
/* obtain unique plugin ID */
my_plugin_id = mysqlnd_plugin_register();
/* snip - see Extending Connection: methods */
}
static MY_CONN_PROPERTIES** get_conn_properties(const MYSQLND *conn TSRMLS_DC) {
MY_CONN_PROPERTIES** props;
props = (MY_CONN_PROPERTIES**)mysqlnd_plugin_get_plugin_connection_data(
conn, my_plugin_id);
if (!props || !(*props)) {
MySQL Native Driver (Mysqlnd)
objects cannot simply add properties to the objects.
mysqlnd
pointer per plugin.
object constructors, which is allowed, you must keep this in
mysqlnd
2549
objects using an appropriate function of the
family. When allocating an object
pointer to arbitrary data.
void *
Contents
Beginning of the mysqlnd object C struct
End of the mysqlnd object C struct
void* to object data of the m-th plugin
mysqlnd
reserves
mysqlnd

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents