2003-02-12 08:45:53 +08:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
2003-02-22 15:31:01 +08:00
|
|
|
| PHP Version 5 |
|
2003-02-12 08:45:53 +08:00
|
|
|
+----------------------------------------------------------------------+
|
2003-02-22 15:31:01 +08:00
|
|
|
| Copyright (c) 1997-2003 The PHP Group |
|
2003-02-12 08:45:53 +08:00
|
|
|
+----------------------------------------------------------------------+
|
2003-06-11 04:04:29 +08:00
|
|
|
| This source file is subject to version 3.0 of the PHP license, |
|
2003-02-12 08:45:53 +08:00
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
2003-06-11 04:04:29 +08:00
|
|
|
| available through the world-wide-web at the following url: |
|
|
|
|
| http://www.php.net/license/3_0.txt. |
|
2003-02-12 08:45:53 +08:00
|
|
|
| If you did not receive a copy of the PHP license and are unable to |
|
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
| license@php.net so we can mail you a copy immediately. |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Author: Georg Richter <georg@php.net> |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <signal.h>
|
|
|
|
|
|
|
|
#include "php.h"
|
|
|
|
#include "php_ini.h"
|
|
|
|
#include "ext/standard/info.h"
|
2003-02-15 00:49:09 +08:00
|
|
|
#include "ext/standard/php_string.h"
|
2003-02-12 08:45:53 +08:00
|
|
|
#include "php_mysqli.h"
|
|
|
|
|
|
|
|
#define MYSQLI_STORE_RESULT 0
|
|
|
|
#define MYSQLI_USE_RESULT 1
|
|
|
|
|
|
|
|
ZEND_DECLARE_MODULE_GLOBALS(mysqli)
|
|
|
|
static zend_object_handlers mysqli_object_handlers;
|
2003-03-11 09:19:21 +08:00
|
|
|
PR_MAIN *prmain;
|
2003-02-12 08:45:53 +08:00
|
|
|
|
2003-07-15 18:37:19 +08:00
|
|
|
/* {{{ php_free_stmt_bind_buffer */
|
|
|
|
void php_free_stmt_bind_buffer(BIND_BUFFER bbuf, int type)
|
2003-02-15 00:49:09 +08:00
|
|
|
{
|
|
|
|
unsigned int i;
|
2003-02-12 08:45:53 +08:00
|
|
|
|
2003-07-15 18:37:19 +08:00
|
|
|
if (!bbuf.var_cnt) {
|
|
|
|
return;
|
2003-02-22 15:31:01 +08:00
|
|
|
}
|
2003-02-12 08:45:53 +08:00
|
|
|
|
2003-07-15 18:37:19 +08:00
|
|
|
if (bbuf.is_null) {
|
|
|
|
efree(bbuf.is_null);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i=0; i < bbuf.var_cnt; i++) {
|
|
|
|
if (type == FETCH_RESULT) {
|
|
|
|
if (bbuf.buf[i].type == IS_STRING) {
|
|
|
|
efree(bbuf.buf[i].buffer);
|
2003-02-12 08:45:53 +08:00
|
|
|
}
|
|
|
|
}
|
2003-07-15 18:37:19 +08:00
|
|
|
if (bbuf.vars[i]) {
|
|
|
|
ZVAL_DELREF(bbuf.vars[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bbuf.vars) {
|
|
|
|
efree(bbuf.vars);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type == FETCH_RESULT) {
|
|
|
|
efree(bbuf.buf);
|
2003-02-12 08:45:53 +08:00
|
|
|
}
|
2003-07-15 18:37:19 +08:00
|
|
|
bbuf.var_cnt = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ php_clear_stmt_bind */
|
|
|
|
void php_clear_stmt_bind(STMT *stmt)
|
|
|
|
{
|
|
|
|
if (stmt->stmt) {
|
|
|
|
mysql_stmt_close(stmt->stmt);
|
|
|
|
}
|
|
|
|
|
|
|
|
php_free_stmt_bind_buffer(stmt->param, FETCH_SIMPLE);
|
|
|
|
php_free_stmt_bind_buffer(stmt->result, FETCH_RESULT);
|
|
|
|
|
2003-02-12 08:45:53 +08:00
|
|
|
efree(stmt);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ mysqli_objects_dtor
|
|
|
|
*/
|
|
|
|
static void mysqli_objects_dtor(void *object, zend_object_handle handle TSRMLS_DC)
|
|
|
|
{
|
2003-03-09 07:33:12 +08:00
|
|
|
mysqli_object *intern = (mysqli_object *)object;
|
|
|
|
MYSQLI_RESOURCE *my_res = (MYSQLI_RESOURCE *)intern->ptr;
|
2003-02-12 08:45:53 +08:00
|
|
|
|
|
|
|
/* link object */
|
|
|
|
if (intern->zo.ce == mysqli_link_class_entry) {
|
2003-03-09 07:33:12 +08:00
|
|
|
if (my_res && my_res->ptr) {
|
|
|
|
mysql_close(my_res->ptr);
|
2003-02-12 08:45:53 +08:00
|
|
|
}
|
2003-02-15 00:49:09 +08:00
|
|
|
} else if (intern->zo.ce == mysqli_stmt_class_entry) { /* stmt object */
|
2003-03-09 07:33:12 +08:00
|
|
|
if (my_res && my_res->ptr) {
|
|
|
|
php_clear_stmt_bind((STMT *)my_res->ptr);
|
2003-02-12 08:45:53 +08:00
|
|
|
}
|
2003-02-15 00:49:09 +08:00
|
|
|
} else if (intern->zo.ce == mysqli_result_class_entry) { /* result object */
|
2003-03-09 07:33:12 +08:00
|
|
|
if (my_res && my_res->ptr) {
|
|
|
|
mysql_free_result(my_res->ptr);
|
2003-02-12 08:45:53 +08:00
|
|
|
}
|
|
|
|
}
|
2003-03-09 07:33:12 +08:00
|
|
|
my_efree(my_res);
|
2003-02-12 08:45:53 +08:00
|
|
|
zend_objects_destroy_object(object, handle TSRMLS_CC);
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ mysqli_objects_clone
|
|
|
|
*/
|
|
|
|
static void mysqli_objects_clone(void *object, void **object_clone TSRMLS_DC)
|
|
|
|
{
|
|
|
|
/* TODO */
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ mysqli_objects_new
|
|
|
|
*/
|
|
|
|
PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry *class_type TSRMLS_DC)
|
|
|
|
{
|
|
|
|
zend_object_value retval;
|
|
|
|
mysqli_object *intern;
|
|
|
|
zval *tmp;
|
|
|
|
|
|
|
|
intern = emalloc(sizeof(mysqli_object));
|
|
|
|
intern->zo.ce = class_type;
|
|
|
|
intern->zo.in_get = 0;
|
|
|
|
intern->zo.in_set = 0;
|
2003-03-22 02:08:59 +08:00
|
|
|
intern->ptr = NULL;
|
2003-02-12 08:45:53 +08:00
|
|
|
|
|
|
|
ALLOC_HASHTABLE(intern->zo.properties);
|
|
|
|
zend_hash_init(intern->zo.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
|
|
|
|
zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
|
|
|
|
|
|
|
|
retval.handle = zend_objects_store_put(intern, mysqli_objects_dtor, mysqli_objects_clone TSRMLS_CC);
|
|
|
|
retval.handlers = &mysqli_object_handlers;
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ mysqli_module_entry
|
|
|
|
*/
|
|
|
|
zend_module_entry mysqli_module_entry = {
|
|
|
|
#if ZEND_MODULE_API_NO >= 20010901
|
|
|
|
STANDARD_MODULE_HEADER,
|
|
|
|
#endif
|
|
|
|
"mysqli",
|
|
|
|
mysqli_functions,
|
|
|
|
PHP_MINIT(mysqli),
|
|
|
|
PHP_MSHUTDOWN(mysqli),
|
|
|
|
PHP_RINIT(mysqli), /* Replace with NULL if there's nothing to do at request start */
|
|
|
|
PHP_RSHUTDOWN(mysqli), /* Replace with NULL if there's nothing to do at request end */
|
|
|
|
PHP_MINFO(mysqli),
|
|
|
|
#if ZEND_MODULE_API_NO >= 20010901
|
|
|
|
"0.1", /* Replace with version number for your extension */
|
|
|
|
#endif
|
|
|
|
STANDARD_MODULE_PROPERTIES
|
|
|
|
};
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
#ifdef COMPILE_DL_MYSQLI
|
|
|
|
ZEND_GET_MODULE(mysqli)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* {{{ PHP_INI_BEGIN
|
|
|
|
*/
|
|
|
|
PHP_INI_BEGIN()
|
2003-03-07 13:15:28 +08:00
|
|
|
STD_PHP_INI_ENTRY_EX("mysqli.max_links", "-1", PHP_INI_SYSTEM, OnUpdateLong, max_links, zend_mysqli_globals, mysqli_globals, display_link_numbers)
|
2003-02-12 08:45:53 +08:00
|
|
|
STD_PHP_INI_ENTRY("mysqli.default_host", NULL, PHP_INI_ALL, OnUpdateString, default_host, zend_mysqli_globals, mysqli_globals)
|
|
|
|
STD_PHP_INI_ENTRY("mysqli.default_user", NULL, PHP_INI_ALL, OnUpdateString, default_user, zend_mysqli_globals, mysqli_globals)
|
|
|
|
STD_PHP_INI_ENTRY("mysqli.default_pw", NULL, PHP_INI_ALL, OnUpdateString, default_pw, zend_mysqli_globals, mysqli_globals)
|
2003-03-07 13:15:28 +08:00
|
|
|
STD_PHP_INI_ENTRY("mysqli.default_port", "3306", PHP_INI_ALL, OnUpdateLong, default_port, zend_mysqli_globals, mysqli_globals)
|
2003-02-12 08:45:53 +08:00
|
|
|
STD_PHP_INI_ENTRY("mysqli.default_socket", NULL, PHP_INI_ALL, OnUpdateStringUnempty, default_socket, zend_mysqli_globals, mysqli_globals)
|
|
|
|
PHP_INI_END()
|
|
|
|
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ php_mysqli_init_globals
|
|
|
|
*/
|
|
|
|
static void php_mysqli_init_globals(zend_mysqli_globals *mysqli_globals)
|
|
|
|
{
|
|
|
|
mysqli_globals->num_links = 0;
|
|
|
|
mysqli_globals->max_links = 0;
|
|
|
|
mysqli_globals->default_port = 0;
|
|
|
|
mysqli_globals->default_host = NULL;
|
|
|
|
mysqli_globals->default_user = NULL;
|
|
|
|
mysqli_globals->default_pw = NULL;
|
|
|
|
mysqli_globals->default_socket = NULL;
|
2003-03-09 07:33:12 +08:00
|
|
|
mysqli_globals->profiler = 0;
|
2003-02-12 08:45:53 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ PHP_MINIT_FUNCTION
|
|
|
|
*/
|
|
|
|
PHP_MINIT_FUNCTION(mysqli)
|
|
|
|
{
|
|
|
|
|
|
|
|
ZEND_INIT_MODULE_GLOBALS(mysqli, php_mysqli_init_globals, NULL);
|
|
|
|
REGISTER_INI_ENTRIES();
|
|
|
|
|
|
|
|
memcpy(&mysqli_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
|
|
|
|
mysqli_object_handlers.clone_obj = zend_objects_store_clone_obj;
|
|
|
|
|
|
|
|
REGISTER_MYSQLI_CLASS_ENTRY("mysqli", mysqli_link_class_entry, mysqli_link_methods);
|
|
|
|
REGISTER_MYSQLI_CLASS_ENTRY("mysqli_result", mysqli_result_class_entry, mysqli_result_methods);
|
|
|
|
REGISTER_MYSQLI_CLASS_ENTRY("mysqli_stmt", mysqli_stmt_class_entry, mysqli_stmt_methods);
|
|
|
|
|
|
|
|
/* mysqli_options */
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_READ_DEFAULT_GROUP", MYSQL_READ_DEFAULT_GROUP, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_READ_DEFAULT_FILE", MYSQL_READ_DEFAULT_FILE, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_OPT_CONNECT_TIMEOUT", MYSQL_OPT_CONNECT_TIMEOUT, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_OPT_LOCAL_INFILE", MYSQL_OPT_LOCAL_INFILE, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_INIT_COMMAND", MYSQL_INIT_COMMAND, CONST_CS | CONST_PERSISTENT);
|
|
|
|
|
|
|
|
/* mysqli_real_connect flags */
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_SSL", CLIENT_SSL, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_COMPRESS",CLIENT_COMPRESS, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_INTERACTIVE", CLIENT_INTERACTIVE, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_IGNORE_SPACE", CLIENT_IGNORE_SPACE, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_NO_SCHEMA", CLIENT_NO_SCHEMA, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_MULTI_QUERIES", CLIENT_MULTI_QUERIES, CONST_CS | CONST_PERSISTENT);
|
|
|
|
|
|
|
|
|
|
|
|
/* for mysqli_query */
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_STORE_RESULT", 0, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_USE_RESULT", 1, CONST_CS | CONST_PERSISTENT);
|
|
|
|
|
|
|
|
/* for mysqli_fetch_assoc */
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_ASSOC", MYSQLI_ASSOC, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_NUM", MYSQLI_NUM, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_BOTH", MYSQLI_BOTH, CONST_CS | CONST_PERSISTENT);
|
|
|
|
|
|
|
|
|
|
|
|
/* column information */
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_NOT_NULL_FLAG", NOT_NULL_FLAG, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_PRI_KEY_FLAG", PRI_KEY_FLAG, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_UNIQUE_KEY_FLAG", UNIQUE_KEY_FLAG, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_MULTIPLE_KEY_FLAG", MULTIPLE_KEY_FLAG, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_BLOB_FLAG", BLOB_FLAG, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_UNSIGNED_FLAG", UNSIGNED_FLAG, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_ZEROFILL_FLAG", ZEROFILL_FLAG, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_AUTO_INCREMENT_FLAG", AUTO_INCREMENT_FLAG, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TIMESTAMP_FLAG", TIMESTAMP_FLAG, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_SET_FLAG", SET_FLAG, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_NUM_FLAG", NUM_FLAG, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_PART_KEY_FLAG", PART_KEY_FLAG, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_GROUP_FLAG", GROUP_FLAG, CONST_CS | CONST_PERSISTENT);
|
|
|
|
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_DECIMAL", FIELD_TYPE_DECIMAL, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_TINY", FIELD_TYPE_TINY, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_SHORT", FIELD_TYPE_SHORT, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_LONG", FIELD_TYPE_LONG, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_FLOAD", FIELD_TYPE_FLOAT, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_DOUBLE", FIELD_TYPE_DOUBLE, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_NULL", FIELD_TYPE_NULL, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_TIMESTAMP", FIELD_TYPE_TIMESTAMP, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_LONGLONG", FIELD_TYPE_LONGLONG, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_INT24", FIELD_TYPE_INT24, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_DATE", FIELD_TYPE_DATE, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_TIME", FIELD_TYPE_TIME, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_DATETIME", FIELD_TYPE_DATETIME , CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_YEAR", FIELD_TYPE_YEAR, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_NEWDATE", FIELD_TYPE_NEWDATE, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_ENUM", FIELD_TYPE_ENUM, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_SET", FIELD_TYPE_SET, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_TINY_BLOB", FIELD_TYPE_TINY_BLOB, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_MEDIUM_BLOB", FIELD_TYPE_MEDIUM_BLOB, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_LONG_BLOB", FIELD_TYPE_LONG_BLOB, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_BLOB", FIELD_TYPE_BLOB, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_VAR_STRING", FIELD_TYPE_VAR_STRING, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_STRING", FIELD_TYPE_STRING, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_CHAR", FIELD_TYPE_CHAR, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_INTERVAL", FIELD_TYPE_INTERVAL, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_GEOMETRY", FIELD_TYPE_GEOMETRY, CONST_CS | CONST_PERSISTENT);
|
|
|
|
|
|
|
|
/* bindtypes for mysqli_bind_result */
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_BIND_STRING", MYSQLI_BIND_STRING, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_BIND_INT", MYSQLI_BIND_INT, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_BIND_DOUBLE", MYSQLI_BIND_DOUBLE, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_BIND_SEND_DATA", MYSQLI_BIND_SEND_DATA, CONST_CS | CONST_PERSISTENT);
|
|
|
|
|
|
|
|
/* replication */
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_RPL_MASTER", MYSQL_RPL_MASTER, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_RPL_SLAVE", MYSQL_RPL_SLAVE, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_RPL_ADMIN", MYSQL_RPL_ADMIN, CONST_CS | CONST_PERSISTENT);
|
|
|
|
|
|
|
|
/* bind blob support */
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_NO_DATA", MYSQL_NO_DATA, CONST_CS | CONST_PERSISTENT);
|
2003-03-11 09:19:21 +08:00
|
|
|
|
|
|
|
/* profiler support */
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_PR_REPORT_STDERR", 1, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_PR_REPORT_PORT", 2, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_PR_REPORT_FILE", 3, CONST_CS | CONST_PERSISTENT);
|
|
|
|
|
2003-02-12 08:45:53 +08:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ PHP_MSHUTDOWN_FUNCTION
|
|
|
|
*/
|
|
|
|
PHP_MSHUTDOWN_FUNCTION(mysqli)
|
|
|
|
{
|
|
|
|
/* uncomment this line if you have INI entries
|
|
|
|
UNREGISTER_INI_ENTRIES();
|
|
|
|
*/
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* Remove if there's nothing to do at request start */
|
|
|
|
/* {{{ PHP_RINIT_FUNCTION
|
|
|
|
*/
|
|
|
|
PHP_RINIT_FUNCTION(mysqli)
|
|
|
|
{
|
2003-02-15 00:49:09 +08:00
|
|
|
MyG(error_msg) = NULL;
|
|
|
|
MyG(error_no) = 0;
|
|
|
|
|
2003-02-12 08:45:53 +08:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* Remove if there's nothing to do at request end */
|
|
|
|
/* {{{ PHP_RSHUTDOWN_FUNCTION
|
|
|
|
*/
|
|
|
|
PHP_RSHUTDOWN_FUNCTION(mysqli)
|
|
|
|
{
|
2003-02-15 00:49:09 +08:00
|
|
|
if (MyG(error_msg)) {
|
|
|
|
efree(MyG(error_msg));
|
|
|
|
}
|
|
|
|
|
2003-03-11 09:19:21 +08:00
|
|
|
if (MyG(profiler)) {
|
|
|
|
if (prmain->header.child) {
|
|
|
|
php_mysqli_profiler_report((PR_COMMON *)prmain, 0);
|
|
|
|
}
|
|
|
|
switch (prmain->mode) {
|
|
|
|
case MYSQLI_PR_REPORT_FILE:
|
|
|
|
fclose(prmain->fp);
|
|
|
|
efree(prmain->name);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-02-12 08:45:53 +08:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ PHP_MINFO_FUNCTION
|
|
|
|
*/
|
|
|
|
PHP_MINFO_FUNCTION(mysqli)
|
|
|
|
{
|
|
|
|
php_info_print_table_start();
|
|
|
|
php_info_print_table_header(2, "MysqlI Support", "enabled");
|
|
|
|
php_info_print_table_row(2, "Client API version", mysql_get_client_info());
|
|
|
|
php_info_print_table_row(2, "MYSQLI_SOCKET", MYSQL_UNIX_ADDR);
|
|
|
|
|
|
|
|
|
|
|
|
php_info_print_table_end();
|
|
|
|
|
|
|
|
DISPLAY_INI_ENTRIES();
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ php_mysqli_fetch_into_hash
|
|
|
|
*/
|
|
|
|
void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags)
|
|
|
|
{
|
2003-03-09 07:33:12 +08:00
|
|
|
MYSQL_RES *result;
|
|
|
|
zval *mysql_result;
|
|
|
|
int fetchtype;
|
|
|
|
int copyflag;
|
|
|
|
unsigned int i;
|
|
|
|
MYSQL_FIELD *fields;
|
|
|
|
MYSQL_ROW row;
|
|
|
|
unsigned long *field_len;
|
|
|
|
PR_RESULT *prresult;
|
|
|
|
PR_COMMAND *prcommand;
|
2003-02-12 08:45:53 +08:00
|
|
|
|
|
|
|
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|l", &mysql_result, mysqli_result_class_entry, &fetchtype) == FAILURE) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ZEND_NUM_ARGS() < 2 && !override_flags) {
|
|
|
|
fetchtype = MYSQLI_BOTH;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (override_flags) {
|
|
|
|
fetchtype = override_flags;
|
|
|
|
}
|
|
|
|
|
2003-03-09 07:33:12 +08:00
|
|
|
MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, prresult, PR_RESULT *, &mysql_result, "mysqli_result");
|
|
|
|
|
|
|
|
MYSQLI_PROFILER_COMMAND_START(prcommand, prresult);
|
2003-02-12 08:45:53 +08:00
|
|
|
|
|
|
|
fields = mysql_fetch_fields(result);
|
2003-02-22 15:31:01 +08:00
|
|
|
if (!(row = mysql_fetch_row(result))) {
|
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
2003-03-09 07:33:12 +08:00
|
|
|
|
2003-02-22 15:31:01 +08:00
|
|
|
array_init(return_value);
|
2003-02-12 08:45:53 +08:00
|
|
|
field_len = mysql_fetch_lengths(result);
|
|
|
|
|
2003-02-15 00:49:09 +08:00
|
|
|
for (i = 0; i < mysql_num_fields(result); i++) {
|
2003-02-12 08:45:53 +08:00
|
|
|
if (row[i]) {
|
|
|
|
char *column;
|
2003-02-15 00:49:09 +08:00
|
|
|
int column_len;
|
2003-02-12 08:45:53 +08:00
|
|
|
|
|
|
|
/* check if we need magic quotes */
|
|
|
|
if (PG(magic_quotes_runtime)) {
|
|
|
|
column = php_addslashes(row[i], field_len[i], &column_len, 0 TSRMLS_CC);
|
|
|
|
copyflag = 0;
|
2003-02-15 00:49:09 +08:00
|
|
|
} else {
|
2003-02-12 08:45:53 +08:00
|
|
|
column = row[i];
|
|
|
|
column_len = field_len[i];
|
|
|
|
copyflag = 1;
|
|
|
|
}
|
|
|
|
if (fetchtype & MYSQLI_NUM) {
|
|
|
|
add_index_stringl(return_value, i, column, column_len, copyflag);
|
|
|
|
copyflag = 1;
|
|
|
|
}
|
|
|
|
if (fetchtype & MYSQLI_ASSOC) {
|
|
|
|
add_assoc_stringl(return_value, fields[i].name, column, column_len, copyflag);
|
|
|
|
}
|
2003-02-15 00:49:09 +08:00
|
|
|
} else {
|
2003-02-12 08:45:53 +08:00
|
|
|
if (fetchtype & MYSQLI_NUM) {
|
|
|
|
add_index_null(return_value, i);
|
|
|
|
}
|
|
|
|
if (fetchtype & MYSQLI_ASSOC) {
|
|
|
|
add_assoc_null(return_value, fields[i].name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-03-09 07:33:12 +08:00
|
|
|
|
|
|
|
if (MyG(profiler)) {
|
2003-03-11 09:19:21 +08:00
|
|
|
char tmp[10];
|
|
|
|
sprintf ((char *)&tmp,"row[%d]", mysql_num_fields(result));
|
|
|
|
MYSQLI_PROFILER_COMMAND_RETURNSTRING(prcommand, tmp);
|
2003-03-09 07:33:12 +08:00
|
|
|
prresult->fetched_rows++;
|
|
|
|
}
|
2003-02-12 08:45:53 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2003-02-15 00:49:09 +08:00
|
|
|
/* {{{ php_mysqli_set_error
|
|
|
|
*/
|
|
|
|
PHP_MYSQLI_API void php_mysqli_set_error(long mysql_errno, char *mysql_err TSRMLS_DC)
|
|
|
|
{
|
|
|
|
MyG(error_no) = mysql_errno;
|
|
|
|
if (MyG(error_msg)) {
|
|
|
|
efree(MyG(error_msg));
|
|
|
|
}
|
|
|
|
MyG(error_msg) = estrdup(mysql_err);
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2003-02-12 08:45:53 +08:00
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* tab-width: 4
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* End:
|
|
|
|
* vim600: noet sw=4 ts=4 fdm=marker
|
|
|
|
* vim<600: noet sw=4 ts=4
|
|
|
|
*/
|