I have tried to connect MySQL with C++ and MySQL connector. My simple PHP extension "Hello World" run normally, but when I added a function to access MySQL, so Wamp not working. I hope receice your supports. Thank you very much, I am sorry about my English skill. My code like follow.
#include "stdafx.h"
ZEND_FUNCTION(fetch_talkphp_links);
ZEND_FUNCTION(haha);
zend_function_entry dll_ver_01_functions[] = {
ZEND_FE(haha, NULL)
{NULL, NULL, NULL}
};
zend_module_entry dll_ver_01_module_entry = {
STANDARD_MODULE_HEADER,
"dll_ver_01",
dll_ver_01_functions,
NULL, NULL, NULL, NULL, NULL,
"1.0",
STANDARD_MODULE_PROPERTIES
};
ZEND_GET_MODULE(dll_ver_01);
ZEND_FUNCTION(fetch_talkphp_links)
{
bool useHtml = false;
char *link = "";
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &useHtml) == FAILURE)
{
RETURN_STRING("Missing Parameter", true);
}
if (useHtml == true)
{
link = "<a href=\"http://www.google.com.vn\">Google</a>";
}
else
{
link = "http://www.google.com.vn";
}
RETURN_STRING(link, true);
}
PHP_FUNCTION(haha)
{
sql::Driver *driver;
sql::Connection *con;
sql::Statement *stmt;
sql::ResultSet *res;
driver = get_driver_instance();
con = driver->connect("tcp://127.0.0.1:3306","root","");
RETURN_STRING("ma truong anh",true);
}
I have tried to debug, so I think method
driver = get_driver_instance(); makes Wamp not working.