static enum_func_status mysqlnd_send_close(MYSQLND * conn TSRMLS_DC);
-
-/* {{{ mysqlnd_library_init */
-void mysqlnd_library_init(TSRMLS_D)
-{
- if (mysqlnd_library_initted == FALSE) {
- mysqlnd_library_initted = TRUE;
- _mysqlnd_init_ps_subsystem();
- /* Should be calloc, as mnd_calloc will reference LOCK_access*/
- mysqlnd_stats_init(&mysqlnd_global_stats);
- }
-}
-/* }}} */
-
+static struct st_mysqlnd_conn_methods *mysqlnd_conn_methods;
/* {{{ mysqlnd_library_end */
void mysqlnd_library_end(TSRMLS_D)
MYSQLND_STMT * _mysqlnd_stmt_init(MYSQLND * const conn TSRMLS_DC);
-
MYSQLND_CLASS_METHODS_START(mysqlnd_conn)
MYSQLND_METHOD(mysqlnd_conn, escape_string),
MYSQLND_METHOD(mysqlnd_conn, set_charset),
SET_ERROR_AFF_ROWS(ret);
ret->persistent = persistent;
- ret->m = & mysqlnd_mysqlnd_conn_methods;
+ ret->m = mysqlnd_conn_methods;
ret->m->get_reference(ret TSRMLS_CC);
#ifdef MYSQLND_THREADED
}
/* }}} */
+/* {{{ mysqlnd_library_init */
+void mysqlnd_library_init(TSRMLS_D)
+{
+ if (mysqlnd_library_initted == FALSE) {
+ mysqlnd_library_initted = TRUE;
+ mysqlnd_conn_methods = &MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_conn);
+ _mysqlnd_init_ps_subsystem();
+ /* Should be calloc, as mnd_calloc will reference LOCK_access*/
+ mysqlnd_stats_init(&mysqlnd_global_stats);
+ }
+}
+/* }}} */
+
+/* {{{ mysqlnd_conn_get_methods */
+PHPAPI struct st_mysqlnd_conn_methods * mysqlnd_conn_get_methods()
+{
+ return mysqlnd_conn_methods;
+}
+/* }}} */
+
+/* {{{ mysqlnd_conn_set_methods */
+PHPAPI void mysqlnd_conn_set_methods(struct st_mysqlnd_conn_methods *methods)
+{
+ mysqlnd_conn_methods = methods;
+}
+/* }}} */
/*
* Local variables:
void mysqlnd_library_init(TSRMLS_D);
void mysqlnd_library_end(TSRMLS_D);
+PHPAPI struct st_mysqlnd_conn_methods * mysqlnd_conn_get_methods();
+PHPAPI void mysqlnd_conn_set_methods(struct st_mysqlnd_conn_methods *methods);
+
+PHPAPI struct st_mysqlnd_stmt_methods * mysqlnd_stmt_get_methods();
+PHPAPI void mysqlnd_stmt_set_methods(struct st_mysqlnd_stmt_methods *methods);
+
+
#define mysqlnd_restart_psession(conn, cache) _mysqlnd_restart_psession((conn), (cache) TSRMLS_CC)
PHPAPI void _mysqlnd_restart_psession(MYSQLND *conn, MYSQLND_THD_ZVAL_PCACHE *cache TSRMLS_DC);
#define mysqlnd_end_psession(conn) _mysqlnd_end_psession((conn) TSRMLS_CC)
void mysqlnd_qcache_put(MYSQLND_QCACHE * const cache, char * query, size_t query_len,
MYSQLND_RES_BUFFERED * const result, MYSQLND_RES_METADATA * const meta);
-
+/* double check the class name to avoid naming conflicts when using these: */
+#define MYSQLND_METHOD(class, method) php_##class##_##method##_pub
+#define MYSQLND_METHOD_PRIVATE(class, method) php_##class##_##method##_priv
ZEND_BEGIN_MODULE_GLOBALS(mysqlnd)
zend_bool collect_statistics;
#define pestrndup(s, length, persistent) ((persistent)?zend_strndup((s),(length)):estrndup((s),(length)))
#endif
-
+#define MYSQLND_CLASS_METHOD_TABLE_NAME(class) mysqlnd_##class##_methods
#define MYSQLND_CLASS_METHODS_START(class) static \
- struct st_##class##_methods mysqlnd_##class##_methods = {
+ struct st_##class##_methods MYSQLND_CLASS_METHOD_TABLE_NAME(class) = {
#define MYSQLND_CLASS_METHODS_END }
-#define MYSQLND_METHOD(class, method) php_##class##_##method##_pub
-#define MYSQLND_METHOD_PRIVATE(class, method) php_##class##_##method##_priv
#if PHP_MAJOR_VERSION < 6
#define mysqlnd_array_init(arg, field_count) \
enum_func_status mysqlnd_handle_local_infile(MYSQLND *conn, const char *filename, zend_bool *is_warning TSRMLS_DC);
+
void _mysqlnd_init_ps_subsystem();/* This one is private, mysqlnd_library_init() will call it */
+void _mysqlnd_init_ps_fetch_subsystem();
void ps_fetch_from_1_to_8_bytes(zval *zv, const MYSQLND_FIELD * const field,
unsigned int pack_len, zend_uchar **row, zend_bool as_unicode,
const char * const mysqlnd_not_bound_as_blob = "Can't send long data for non-string/non-binary data types";
const char * const mysqlnd_stmt_not_prepared = "Statement not prepared";
+static struct st_mysqlnd_stmt_methods *mysqlnd_stmt_methods;
+
/* Exported by mysqlnd.c */
enum_func_status mysqlnd_simple_command(MYSQLND *conn, enum php_mysqlnd_server_command command,
const char * const arg, size_t arg_len,
/* }}} */
-static
-struct st_mysqlnd_stmt_methods mysqlnd_stmt_methods = {
+MYSQLND_CLASS_METHODS_START(mysqlnd_stmt)
MYSQLND_METHOD(mysqlnd_stmt, prepare),
MYSQLND_METHOD(mysqlnd_stmt, execute),
MYSQLND_METHOD(mysqlnd_stmt, use_result),
MYSQLND_METHOD(mysqlnd_stmt, attr_get),
MYSQLND_METHOD(mysqlnd_stmt, attr_set),
-};
+MYSQLND_CLASS_METHODS_END;
/* {{{ _mysqlnd_stmt_init */
DBG_ENTER("_mysqlnd_stmt_init");
DBG_INF_FMT("stmt=%p", stmt);
- stmt->m = &mysqlnd_stmt_methods;
+ stmt->m = mysqlnd_stmt_methods;
stmt->state = MYSQLND_STMT_INITTED;
stmt->execute_cmd_buffer.length = 4096;
stmt->execute_cmd_buffer.buffer = mnd_emalloc(stmt->execute_cmd_buffer.length);
}
/* }}} */
+/* {{{ _mysqlnd_init_ps_subsystem */
+void _mysqlnd_init_ps_subsystem()
+{
+ mysqlnd_stmt_methods = &MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_stmt);
+ _mysqlnd_init_ps_fetch_subsystem();
+}
+/* }}} */
+
+/* {{{ mysqlnd_conn_get_methods */
+PHPAPI struct st_mysqlnd_stmt_methods * mysqlnd_stmt_get_methods()
+{
+ return mysqlnd_stmt_methods;
+}
+/* }}} */
+
+/* {{{ mysqlnd_conn_set_methods */
+PHPAPI void mysqlnd_stmt_set_methods(struct st_mysqlnd_stmt_methods *methods)
+{
+ mysqlnd_stmt_methods = methods;
+}
+/* }}} */
+
/*
* Local variables:
/* }}} */
-/* {{{ _mysqlnd_init_ps_subsystem */
-void _mysqlnd_init_ps_subsystem()
+/* {{{ _mysqlnd_init_ps_fetch_subsystem */
+void _mysqlnd_init_ps_fetch_subsystem()
{
memset(mysqlnd_ps_fetch_functions, 0, sizeof(mysqlnd_ps_fetch_functions));
mysqlnd_ps_fetch_functions[MYSQL_TYPE_NULL].func = ps_fetch_null;