I write a code for build an extension to connect to mysql database via mysql_connect
.
My code is compiled, but when I want to use my function in PHP, it take a loop and not work probably. here is my C++ code:
PHP_FUNCTION(ig_connect_to_database)
{
zval fname, *args[3], *retval = NULL;
ZVAL_STRING(&fname, "mysql_connect", 0);
MAKE_STD_ZVAL(args[0]);
ZVAL_STRING(args[0], "localhost", 1);
MAKE_STD_ZVAL(args[1]);
ZVAL_STRING(args[1], "root", 1);
MAKE_STD_ZVAL(args[2]);
ZVAL_STRING(args[2], "", 1);
if (call_user_function(EG(function_table), NULL, &fname, retval, 3, args TSRMLS_CC) == SUCCESS) {
zval_ptr_dtor(&retval);
zval_ptr_dtor(&args[1]);
zval_ptr_dtor(&args[0]);
}
}
any body can help me?
I just want to return my resource connection.
I know that "retval" is myresource but I do not know how can return this resource into my php code.