if (!conn_handle) {
self_alloced = TRUE;
- if (!(conn_handle = mysqlnd_connection_init(client_api_flags, FALSE))) {
+ if (!(conn_handle = mysqlnd_connection_init(client_api_flags, FALSE, NULL))) {
/* OOM */
DBG_RETURN(NULL);
}
MYSQLND_METHOD(mysqlnd_conn_data, stmt_init)(MYSQLND_CONN_DATA * const conn)
{
MYSQLND_STMT * ret;
- DBG_ENTER("_mysqlnd_stmt_init");
- ret = MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_object_factory).get_prepared_statement(conn, conn->persistent);
+ DBG_ENTER("mysqlnd_conn_data::stmt_init");
+ ret = conn->object_factory.get_prepared_statement(conn, conn->persistent);
DBG_RETURN(ret);
}
/* }}} */
{
MYSQLND * ret;
DBG_ENTER("mysqlnd_conn::get_reference");
- ret = MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_object_factory).clone_connection_object(conn);
+ ret = conn->data->object_factory.clone_connection_object(conn);
DBG_RETURN(ret);
}
/* }}} */
/* {{{ mysqlnd_connection_init */
PHPAPI MYSQLND *
-mysqlnd_connection_init(unsigned int client_flags, zend_bool persistent)
+mysqlnd_connection_init(unsigned int client_flags, zend_bool persistent, struct st_mysqlnd_object_factory_methods * object_factory)
{
+ struct st_mysqlnd_object_factory_methods * factory = object_factory? object_factory : &MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_object_factory);
MYSQLND * ret;
DBG_ENTER("mysqlnd_connection_init");
- ret = MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_object_factory).get_connection(persistent);
+ ret = factory->get_connection(factory, persistent);
if (ret && ret->data) {
ret->data->m->negotiate_client_api_capabilities(ret->data, client_flags);
}
/* Connect */
-#define mysqlnd_init(flags, persistent) mysqlnd_connection_init((flags), (persistent))
+#define mysqlnd_init(flags, persistent) mysqlnd_connection_init((flags), (persistent), NULL /*use default factory*/)
#define mysqlnd_connect(conn, host, user, pass, pass_len, db, db_len, port, socket, mysql_flags, client_api_flags) \
mysqlnd_connection_connect((conn), (host), (user), (pass), (pass_len), (db), (db_len), (port), (socket), (mysql_flags), (client_api_flags))
-PHPAPI MYSQLND * mysqlnd_connection_init(unsigned int client_flags, zend_bool persistent);
+PHPAPI MYSQLND * mysqlnd_connection_init(unsigned int client_flags, zend_bool persistent, struct st_mysqlnd_object_factory_methods * object_factory);
PHPAPI MYSQLND * mysqlnd_connection_connect(MYSQLND * conn,
const char * host, const char * user,
const char * passwd, unsigned int passwd_len,
/* {{{ mysqlnd_object_factory::get_connection */
static MYSQLND *
-MYSQLND_METHOD(mysqlnd_object_factory, get_connection)(zend_bool persistent)
+MYSQLND_METHOD(mysqlnd_object_factory, get_connection)(struct st_mysqlnd_object_factory_methods * factory, zend_bool persistent)
{
size_t alloc_size_ret = sizeof(MYSQLND) + mysqlnd_plugin_count() * sizeof(void *);
size_t alloc_size_ret_data = sizeof(MYSQLND_CONN_DATA) + mysqlnd_plugin_count() * sizeof(void *);
data->persistent = persistent;
data->m = mysqlnd_conn_data_get_methods();
+ data->object_factory = *factory;
CONN_SET_STATE(data, CONN_ALLOCED);
data->m->get_reference(data);
};
-typedef MYSQLND * (*func_mysqlnd_object_factory__get_connection)(zend_bool persistent);
+struct st_mysqlnd_object_factory_methods;
+
+typedef MYSQLND * (*func_mysqlnd_object_factory__get_connection)(struct st_mysqlnd_object_factory_methods * factory, zend_bool persistent);
typedef MYSQLND * (*func_mysqlnd_object_factory__clone_connection_object)(MYSQLND * conn);
typedef MYSQLND_STMT * (*func_mysqlnd_object_factory__get_prepared_statement)(MYSQLND_CONN_DATA * conn, zend_bool persistent);
typedef MYSQLND_NET * (*func_mysqlnd_object_factory__get_io_channel)(zend_bool persistent, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info);
zend_bool in_async_read_cb;
zend_bool in_async_err_cb;
+ struct st_mysqlnd_object_factory_methods object_factory;
+
struct st_mysqlnd_conn_data_methods * m;
/* persistent connection */