mirror of
https://github.com/php/php-src.git
synced 2025-01-23 20:23:31 +08:00
initial upload
This commit is contained in:
parent
1fc7f0d937
commit
7d7c07a77c
2
ext/mysqli/CREDITS
Normal file
2
ext/mysqli/CREDITS
Normal file
@ -0,0 +1,2 @@
|
||||
MySQLi
|
||||
Zak Greant, Georg Richter
|
0
ext/mysqli/EXPERIMENTAL
Normal file
0
ext/mysqli/EXPERIMENTAL
Normal file
13
ext/mysqli/TODO
Normal file
13
ext/mysqli/TODO
Normal file
@ -0,0 +1,13 @@
|
||||
- review/code inspection of the bind stuff
|
||||
- test
|
||||
- documentation
|
||||
- benchmarks /ext/mysql vs. ext/mysqli
|
||||
- testing/compiling under windows
|
||||
- migration guide:
|
||||
diffrences between ext/mysql and mysqli
|
||||
not supported functions from ext/mysql (mysql_db_query)
|
||||
- ini-settings
|
||||
- phpinfo output (Status: mostly done, maybe some more information could be interesting)
|
||||
- blob support for mysql_prepare
|
||||
- multi query support (still open until there is a decision (MySQL AB))
|
||||
- bundled libmysql 4.1
|
409
ext/mysqli/mysqli.c
Normal file
409
ext/mysqli/mysqli.c
Normal file
@ -0,0 +1,409 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2002 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.txt. |
|
||||
| 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"
|
||||
#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;
|
||||
|
||||
/* {{{ php_clear_stmt_bind */
|
||||
void php_clear_stmt_bind(STMT *stmt) {
|
||||
int i;
|
||||
|
||||
|
||||
if (stmt->stmt)
|
||||
mysql_stmt_close(stmt->stmt);
|
||||
|
||||
if (stmt->var_cnt) {
|
||||
|
||||
for (i=0; i < stmt->var_cnt; i++) {
|
||||
if (stmt->type == FETCH_RESULT) {
|
||||
if (stmt->bind[i].type == IS_STRING) {
|
||||
efree(stmt->bind[i].buffer);
|
||||
}
|
||||
}
|
||||
if (stmt->vars[i]) {
|
||||
ZVAL_DELREF(stmt->vars[i]);
|
||||
}
|
||||
}
|
||||
if (stmt->type == FETCH_RESULT) {
|
||||
efree(stmt->bind);
|
||||
}
|
||||
efree(stmt->vars);
|
||||
efree(stmt->is_null);
|
||||
}
|
||||
efree(stmt);
|
||||
return;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ mysqli_objects_dtor
|
||||
*/
|
||||
static void mysqli_objects_dtor(void *object, zend_object_handle handle TSRMLS_DC)
|
||||
{
|
||||
mysqli_object *intern = (mysqli_object *)object;
|
||||
|
||||
/* link object */
|
||||
if (intern->zo.ce == mysqli_link_class_entry) {
|
||||
MYSQL *mysql = (MYSQL *)intern->ptr;
|
||||
if (mysql) {
|
||||
mysql_close(mysql);
|
||||
}
|
||||
}
|
||||
/* stmt object */
|
||||
else if (intern->zo.ce == mysqli_stmt_class_entry) {
|
||||
STMT *stmt = (STMT *)intern->ptr;
|
||||
if (stmt) {
|
||||
php_clear_stmt_bind(stmt);
|
||||
}
|
||||
}
|
||||
/* result object */
|
||||
else if (intern->zo.ce == mysqli_result_class_entry) {
|
||||
MYSQL_RES *res = (MYSQL_RES *)intern->ptr;
|
||||
if (res) {
|
||||
mysql_free_result(res);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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()
|
||||
STD_PHP_INI_ENTRY_EX("mysqli.max_links", "-1", PHP_INI_SYSTEM, OnUpdateInt, max_links, zend_mysqli_globals, mysqli_globals, display_link_numbers)
|
||||
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)
|
||||
STD_PHP_INI_ENTRY("mysqli.default_port", "3306", PHP_INI_ALL, OnUpdateInt, default_port, zend_mysqli_globals, mysqli_globals)
|
||||
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;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ 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_NEED_DATA", MYSQL_NEED_DATA, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_NO_DATA", MYSQL_NO_DATA, CONST_CS | CONST_PERSISTENT);
|
||||
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)
|
||||
{
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* Remove if there's nothing to do at request end */
|
||||
/* {{{ PHP_RSHUTDOWN_FUNCTION
|
||||
*/
|
||||
PHP_RSHUTDOWN_FUNCTION(mysqli)
|
||||
{
|
||||
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)
|
||||
{
|
||||
MYSQL_RES *result;
|
||||
zval *mysql_result;
|
||||
int fetchtype;
|
||||
int copyflag, i;
|
||||
MYSQL_FIELD *fields;
|
||||
MYSQL_ROW row;
|
||||
unsigned long *field_len;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result");
|
||||
|
||||
if (array_init(return_value) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
fields = mysql_fetch_fields(result);
|
||||
row = mysql_fetch_row(result);
|
||||
field_len = mysql_fetch_lengths(result);
|
||||
|
||||
for (i=0; i < mysql_num_fields(result); i++){
|
||||
if (row[i]) {
|
||||
char *column;
|
||||
int column_len;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
else {
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
if (fetchtype & MYSQLI_NUM) {
|
||||
add_index_null(return_value, i);
|
||||
}
|
||||
if (fetchtype & MYSQLI_ASSOC) {
|
||||
add_assoc_null(return_value, fields[i].name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/*
|
||||
* 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
|
||||
*/
|
1678
ext/mysqli/mysqli_api.c
Normal file
1678
ext/mysqli/mysqli_api.c
Normal file
File diff suppressed because it is too large
Load Diff
227
ext/mysqli/mysqli_fe.c
Normal file
227
ext/mysqli/mysqli_fe.c
Normal file
@ -0,0 +1,227 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2002 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.txt. |
|
||||
| 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"
|
||||
#include "php_mysqli.h"
|
||||
|
||||
|
||||
/* {{{ mysqli_functions[]
|
||||
*
|
||||
* Every user visible function must have an entry in mysqli_functions[].
|
||||
*/
|
||||
function_entry mysqli_functions[] = {
|
||||
PHP_FE(mysqli_affected_rows, NULL)
|
||||
PHP_FE(mysqli_autocommit, NULL)
|
||||
PHP_FE(mysqli_bind_param, NULL)
|
||||
PHP_FE(mysqli_bind_result, NULL)
|
||||
PHP_FE(mysqli_change_user, NULL)
|
||||
PHP_FE(mysqli_character_set_name, NULL)
|
||||
PHP_FALIAS(mysqli_client_encoding,
|
||||
mysqli_character_set_name, NULL)
|
||||
PHP_FE(mysqli_close, NULL)
|
||||
PHP_FE(mysqli_commit, NULL)
|
||||
PHP_FE(mysqli_connect, NULL)
|
||||
PHP_FE(mysqli_data_seek, NULL)
|
||||
PHP_FE(mysqli_debug, NULL)
|
||||
PHP_FE(mysqli_disable_reads_from_master, NULL)
|
||||
PHP_FE(mysqli_disable_rpl_parse, NULL)
|
||||
PHP_FE(mysqli_dump_debug_info, NULL)
|
||||
PHP_FE(mysqli_enable_reads_from_master, NULL)
|
||||
PHP_FE(mysqli_enable_rpl_parse, NULL)
|
||||
PHP_FE(mysqli_errno, NULL)
|
||||
PHP_FE(mysqli_error, NULL)
|
||||
PHP_FE(mysqli_execute, NULL)
|
||||
PHP_FE(mysqli_fetch, NULL)
|
||||
PHP_FE(mysqli_fetch_field, NULL)
|
||||
PHP_FE(mysqli_fetch_fields, NULL)
|
||||
PHP_FE(mysqli_fetch_field_direct, NULL)
|
||||
PHP_FE(mysqli_fetch_lengths, NULL)
|
||||
PHP_FE(mysqli_fetch_array, NULL)
|
||||
PHP_FE(mysqli_fetch_assoc, NULL)
|
||||
PHP_FE(mysqli_fetch_object, NULL)
|
||||
PHP_FE(mysqli_fetch_row, NULL)
|
||||
PHP_FE(mysqli_field_count, NULL)
|
||||
PHP_FE(mysqli_field_seek, NULL)
|
||||
PHP_FE(mysqli_field_tell, NULL)
|
||||
PHP_FE(mysqli_free_result, NULL)
|
||||
PHP_FE(mysqli_get_client_info, NULL)
|
||||
PHP_FE(mysqli_get_host_info, NULL)
|
||||
PHP_FE(mysqli_get_proto_info, NULL)
|
||||
PHP_FE(mysqli_get_server_info, NULL)
|
||||
PHP_FE(mysqli_init, NULL)
|
||||
PHP_FE(mysqli_info, NULL)
|
||||
PHP_FE(mysqli_insert_id, NULL)
|
||||
PHP_FE(mysqli_kill, NULL)
|
||||
PHP_FE(mysqli_master_query, NULL)
|
||||
PHP_FE(mysqli_num_fields, NULL)
|
||||
PHP_FE(mysqli_num_rows, NULL)
|
||||
PHP_FE(mysqli_num_warnings, NULL)
|
||||
PHP_FE(mysqli_options, NULL)
|
||||
PHP_FE(mysqli_param_count, NULL)
|
||||
PHP_FE(mysqli_ping, NULL)
|
||||
PHP_FE(mysqli_prepare, NULL)
|
||||
PHP_FE(mysqli_prepare_result, NULL)
|
||||
PHP_FE(mysqli_query, NULL)
|
||||
PHP_FE(mysqli_read_query_result, NULL)
|
||||
PHP_FE(mysqli_real_connect, NULL)
|
||||
PHP_FE(mysqli_real_escape_string, NULL)
|
||||
PHP_FALIAS(mysqli_escape_string,
|
||||
mysqli_real_escape_string, NULL)
|
||||
PHP_FE(mysqli_real_query, NULL)
|
||||
PHP_FE(mysqli_reload, NULL)
|
||||
PHP_FE(mysqli_rollback, NULL)
|
||||
PHP_FE(mysqli_rpl_parse_enabled, NULL)
|
||||
PHP_FE(mysqli_rpl_probe, NULL)
|
||||
PHP_FE(mysqli_rpl_query_type, NULL)
|
||||
PHP_FE(mysqli_select_db, NULL)
|
||||
PHP_FE(mysqli_send_long_data, NULL)
|
||||
PHP_FE(mysqli_send_query, NULL)
|
||||
PHP_FALIAS(mysqli_set_opt, mysqli_options, NULL)
|
||||
PHP_FE(mysqli_slave_query, NULL)
|
||||
PHP_FE(mysqli_ssl_set, NULL)
|
||||
PHP_FE(mysqli_stat, NULL)
|
||||
PHP_FE(mysqli_stmt_close, NULL)
|
||||
PHP_FE(mysqli_stmt_errno, NULL)
|
||||
PHP_FE(mysqli_stmt_error, NULL)
|
||||
PHP_FE(mysqli_store_result, NULL)
|
||||
PHP_FE(mysqli_thread_id, NULL)
|
||||
PHP_FE(mysqli_thread_safe, NULL)
|
||||
PHP_FE(mysqli_use_result, NULL)
|
||||
PHP_FE(mysqli_warning_count, NULL)
|
||||
{NULL, NULL, NULL} /* Must be the last line in mysqli_functions[] */
|
||||
};
|
||||
/* }}} */
|
||||
|
||||
/* {{{ mysqli_link_methods[]
|
||||
*
|
||||
* Every user visible function must have an entry in mysqli_functions[].
|
||||
*/
|
||||
function_entry mysqli_link_methods[] = {
|
||||
PHP_FALIAS(affected_rows,mysqli_affected_rows,NULL)
|
||||
PHP_FALIAS(auto_commit,mysqli_autocommit,NULL)
|
||||
PHP_FALIAS(change_user,mysqli_change_user,NULL)
|
||||
PHP_FALIAS(character_set_name,mysqli_character_set_name,NULL)
|
||||
PHP_FALIAS(client_encoding, mysqli_character_set_name,NULL)
|
||||
PHP_FALIAS(close,mysqli_close,NULL)
|
||||
PHP_FALIAS(commit,mysqli_commit,NULL)
|
||||
PHP_FALIAS(connect,mysqli_connect,NULL)
|
||||
PHP_FALIAS(debug,mysqli_debug,NULL)
|
||||
PHP_FALIAS(disable_reads_from_master,mysqli_disable_reads_from_master,NULL)
|
||||
PHP_FALIAS(disable_rpl_parse,mysqli_disable_rpl_parse,NULL)
|
||||
PHP_FALIAS(dump_debug_info,mysqli_dump_debug_info,NULL)
|
||||
PHP_FALIAS(enable_reads_from_master,mysqli_enable_reads_from_master,NULL)
|
||||
PHP_FALIAS(enable_rpl_parse,mysqli_enable_rpl_parse,NULL)
|
||||
PHP_FALIAS(errno,mysqli_errno,NULL)
|
||||
PHP_FALIAS(error,mysqli_error,NULL)
|
||||
PHP_FALIAS(get_client_info,mysqli_get_client_info,NULL)
|
||||
PHP_FALIAS(get_host_info,mysqli_get_host_info,NULL)
|
||||
PHP_FALIAS(get_proto_info,mysqli_get_proto_info,NULL)
|
||||
PHP_FALIAS(get_server_info,mysqli_get_server_info,NULL)
|
||||
PHP_FALIAS(init,mysqli_init,NULL)
|
||||
PHP_FALIAS(info,mysqli_info,NULL)
|
||||
PHP_FALIAS(insert_id,mysqli_insert_id,NULL)
|
||||
PHP_FALIAS(kill,mysqli_kill,NULL)
|
||||
PHP_FALIAS(master_query,mysqli_master_query,NULL)
|
||||
PHP_FALIAS(options,mysqli_options,NULL)
|
||||
PHP_FALIAS(ping,mysqli_ping,NULL)
|
||||
PHP_FALIAS(prepare,mysqli_prepare,NULL)
|
||||
PHP_FALIAS(query,mysqli_query,NULL)
|
||||
PHP_FALIAS(read_query_result,mysqli_read_query_result,NULL)
|
||||
PHP_FALIAS(real_connect,mysqli_real_connect,NULL)
|
||||
PHP_FALIAS(real_escape_string,mysqli_real_escape_string,NULL)
|
||||
PHP_FALIAS(escape_string, mysqli_real_escape_string,NULL)
|
||||
PHP_FALIAS(real_query,mysqli_real_query,NULL)
|
||||
PHP_FALIAS(reload,mysqli_reload,NULL)
|
||||
PHP_FALIAS(rollback,mysqli_rollback,NULL)
|
||||
PHP_FALIAS(rpl_parse_enabled,mysqli_rpl_parse_enabled,NULL)
|
||||
PHP_FALIAS(rpl_probe,mysqli_rpl_probe,NULL)
|
||||
PHP_FALIAS(rpl_query_type,mysqli_rpl_query_type,NULL)
|
||||
PHP_FALIAS(select_db,mysqli_select_db,NULL)
|
||||
PHP_FALIAS(set_opt, mysqli_options,NULL)
|
||||
PHP_FALIAS(slave_query,mysqli_slave_query,NULL)
|
||||
PHP_FALIAS(ssl_set,mysqli_ssl_set,NULL)
|
||||
PHP_FALIAS(stat,mysqli_stat,NULL)
|
||||
PHP_FALIAS(store_result,mysqli_store_result,NULL)
|
||||
PHP_FALIAS(thread_id, mysqli_thread_id,NULL)
|
||||
PHP_FALIAS(thread_safe,mysqli_thread_safe,NULL)
|
||||
PHP_FALIAS(use_result,mysqli_use_result,NULL)
|
||||
PHP_FALIAS(warning_count,mysqli_warning_count,NULL)
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
/* }}} */
|
||||
|
||||
/* {{{ mysqli_result_methods[]
|
||||
*
|
||||
* Every user visible function must have an entry in mysqli_result_functions[].
|
||||
*/
|
||||
function_entry mysqli_result_methods[] = {
|
||||
PHP_FALIAS(data_seek,mysqli_data_seek,NULL)
|
||||
PHP_FALIAS(fetch_field,mysqli_fetch_field,NULL)
|
||||
PHP_FALIAS(fetch_fields,mysqli_fetch_fields,NULL)
|
||||
PHP_FALIAS(fetvh_field_direct,mysqli_fetch_field_direct,NULL)
|
||||
PHP_FALIAS(fetch_lengths,mysqli_fetch_lengths,NULL)
|
||||
PHP_FALIAS(fetch_array,mysqli_fetch_array,NULL)
|
||||
PHP_FALIAS(fetch_assoc,mysqli_fetch_assoc,NULL)
|
||||
PHP_FALIAS(fetch_object,mysqli_fetch_object,NULL)
|
||||
PHP_FALIAS(fetch_row,mysqli_fetch_row,NULL)
|
||||
PHP_FALIAS(field_count,mysqli_field_count,NULL)
|
||||
PHP_FALIAS(field_seek,mysqli_field_seek,NULL)
|
||||
PHP_FALIAS(field_tell,mysqli_field_tell,NULL)
|
||||
PHP_FALIAS(free_result,mysqli_free_result,NULL)
|
||||
PHP_FALIAS(num_fields,mysqli_num_fields,NULL)
|
||||
PHP_FALIAS(num_rows,mysqli_num_rows,NULL)
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
/* }}} */
|
||||
|
||||
/* {{{ mysqli_stmt_methods[]
|
||||
*
|
||||
* Every user visible function must have an entry in mysqli_stmt_functions[].
|
||||
*/
|
||||
function_entry mysqli_stmt_methods[] = {
|
||||
PHP_FALIAS(bind_param,mysqli_bind_param,NULL)
|
||||
PHP_FALIAS(bind_result,mysqli_bind_result,NULL)
|
||||
PHP_FALIAS(execute,mysqli_execute,NULL)
|
||||
PHP_FALIAS(fetch,mysqli_fetch,NULL)
|
||||
PHP_FALIAS(param_count,mysqli_param_count,NULL)
|
||||
PHP_FALIAS(send_long_data,mysqli_send_long_data,NULL)
|
||||
PHP_FALIAS(stmt_close,mysqli_stmt_close,NULL)
|
||||
PHP_FALIAS(stmt_errno,mysqli_stmt_errno,NULL)
|
||||
PHP_FALIAS(stnt_error,mysqli_stmt_error,NULL)
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
/* }}} */
|
||||
|
||||
/*
|
||||
* 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
|
||||
*/
|
141
ext/mysqli/mysqli_nonapi.c
Normal file
141
ext/mysqli/mysqli_nonapi.c
Normal file
@ -0,0 +1,141 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2002 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.txt. |
|
||||
| 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"
|
||||
#include "php_mysqli.h"
|
||||
|
||||
/* {{{ proto resource mysqli_connect([string hostname, [string username, [string passwd, [string dbname, [int port, [string socket]]]]])
|
||||
open a connection to a mysql server */
|
||||
PHP_FUNCTION(mysqli_connect)
|
||||
{
|
||||
MYSQL *mysql;
|
||||
char *hostname = NULL, *username=NULL, *passwd=NULL, *dbname=NULL, *socket=NULL;
|
||||
unsigned int hostname_len, username_len, passwd_len, dbname_len, socket_len;
|
||||
unsigned int port=0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ssssls", &hostname, &hostname_len, &username, &username_len,
|
||||
&passwd, &passwd_len, &dbname, &dbname_len, &port, &socket, &socket_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* TODO: safe mode handling */
|
||||
if (PG(sql_safe_mode)){
|
||||
} else {
|
||||
if (!passwd) {
|
||||
passwd = MyG(default_pw);
|
||||
if (!username){
|
||||
username = MyG(default_user);
|
||||
if (!hostname) {
|
||||
hostname = MyG(default_host);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mysql = mysql_init(NULL);
|
||||
|
||||
if (mysql_real_connect(mysql,hostname,username,passwd,dbname,port,socket,0) == NULL) {
|
||||
/* Save error messages */
|
||||
MyG(error_no) = mysql_errno(mysql);
|
||||
MyG(error_msg) = estrdup(mysql_error(mysql));
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", mysql_error(mysql));
|
||||
/* free mysql structure */
|
||||
mysql_close(mysql);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
MYSQLI_RETURN_RESOURCE(mysql, mysqli_link_class_entry);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto array mysqli_fetch_array (resource result, [int resulttype])
|
||||
*/
|
||||
PHP_FUNCTION(mysqli_fetch_array)
|
||||
{
|
||||
php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto array mysqli_fetch_assoc (resource result)
|
||||
*/
|
||||
PHP_FUNCTION(mysqli_fetch_assoc)
|
||||
{
|
||||
php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MYSQLI_ASSOC);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto array mysqli_fetch_object (resource result)
|
||||
*/
|
||||
PHP_FUNCTION(mysqli_fetch_object)
|
||||
{
|
||||
php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MYSQLI_ASSOC);
|
||||
|
||||
if (Z_TYPE_P(return_value) == IS_ARRAY) {
|
||||
object_and_properties_init(return_value, ZEND_STANDARD_CLASS_DEF_PTR, Z_ARRVAL_P(return_value));
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto resource mysqli_query(resource link, string query, [int resultmode])
|
||||
*/
|
||||
PHP_FUNCTION(mysqli_query) {
|
||||
MYSQL *mysql;
|
||||
zval *mysql_link;
|
||||
MYSQL_RES *result;
|
||||
char *query = NULL;
|
||||
unsigned int query_len;
|
||||
unsigned int resultmode = 0;
|
||||
|
||||
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|l", &mysql_link, mysqli_link_class_entry, &query, &query_len, &resultmode) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link");
|
||||
|
||||
if (mysql_real_query(mysql, query, query_len)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (!mysql_field_count(mysql)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
result = (resultmode == MYSQLI_USE_RESULT) ? mysql_use_result(mysql) : mysql_store_result(mysql);
|
||||
if (!result) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
MYSQLI_RETURN_RESOURCE(result, mysqli_result_class_entry);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/*
|
||||
* 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
|
||||
*/
|
251
ext/mysqli/php_mysqli.h
Normal file
251
ext/mysqli/php_mysqli.h
Normal file
@ -0,0 +1,251 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2002 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.txt. |
|
||||
| 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$
|
||||
*/
|
||||
|
||||
#include <mysql.h>
|
||||
|
||||
#ifndef PHP_MYSQLI_H
|
||||
#define PHP_MYSQLI_H
|
||||
|
||||
typedef struct {
|
||||
ulong buflen;
|
||||
char *buffer;
|
||||
ulong type;
|
||||
} BIND_BUFFER;
|
||||
|
||||
typedef struct {
|
||||
MYSQL_STMT *stmt;
|
||||
unsigned int var_cnt;
|
||||
zval **vars;
|
||||
BIND_BUFFER *bind;
|
||||
char *is_null;
|
||||
char type;
|
||||
} STMT;
|
||||
|
||||
typedef struct _mysqli_object {
|
||||
zend_object zo;
|
||||
void *ptr;
|
||||
} mysqli_object; /* extends zend_object */
|
||||
|
||||
#define phpext_mysqli_ptr &mysqli_module_entry
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
#define PHP_MYSQLI_API __declspec(dllexport)
|
||||
#else
|
||||
#define PHP_MYSQLI_API
|
||||
#endif
|
||||
|
||||
#ifdef ZTS
|
||||
#include "TSRM.h"
|
||||
#endif
|
||||
|
||||
#define PHP_MYSQLI_EXPORT(__type) PHP_MYSQLI_API __type
|
||||
|
||||
extern zend_module_entry mysqli_module_entry;
|
||||
extern function_entry mysqli_functions[];
|
||||
extern function_entry mysqli_link_methods[];
|
||||
extern function_entry mysqli_stmt_methods[];
|
||||
extern function_entry mysqli_result_methods[];
|
||||
extern void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int flag);
|
||||
extern void php_clear_stmt_bind(STMT *stmt);
|
||||
zend_class_entry *mysqli_link_class_entry;
|
||||
zend_class_entry *mysqli_stmt_class_entry;
|
||||
zend_class_entry *mysqli_result_class_entry;
|
||||
|
||||
zend_class_entry _mysqli_link_class_entry;
|
||||
zend_class_entry _mysqli_stmt_class_entry;
|
||||
zend_class_entry _mysqli_result_class_entry;
|
||||
|
||||
PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry * TSRMLS_DC);
|
||||
|
||||
#define REGISTER_MYSQLI_CLASS_ENTRY(name, mysqli_entry, class_functions) { \
|
||||
INIT_CLASS_ENTRY(_##mysqli_entry,name,class_functions); \
|
||||
_##mysqli_entry.create_object = mysqli_objects_new; \
|
||||
mysqli_entry = zend_register_internal_class(&_##mysqli_entry TSRMLS_CC); \
|
||||
} \
|
||||
|
||||
#define MYSQLI_REGISTER_RESOURCE_EX(__ptr, __zval, __ce) \
|
||||
((mysqli_object *) zend_object_store_get_object(__zval TSRMLS_CC))->ptr = __ptr;
|
||||
|
||||
#define MYSQLI_RETURN_RESOURCE(__ptr, __ce) \
|
||||
Z_TYPE_P(return_value) = IS_OBJECT; \
|
||||
(return_value)->value.obj = mysqli_objects_new(__ce TSRMLS_CC); \
|
||||
MYSQLI_REGISTER_RESOURCE_EX(__ptr, return_value, __ce)
|
||||
|
||||
#define MYSQLI_REGISTER_RESOURCE(__ptr, __ce) \
|
||||
{\
|
||||
zval *object = getThis();\
|
||||
if (!object) {\
|
||||
object = return_value;\
|
||||
Z_TYPE_P(object) = IS_OBJECT;\
|
||||
(object)->value.obj = mysqli_objects_new(__ce TSRMLS_CC);\
|
||||
}\
|
||||
MYSQLI_REGISTER_RESOURCE_EX(__ptr, object, __ce)\
|
||||
}
|
||||
|
||||
#define MYSQLI_FETCH_RESOURCE(__ptr, __type, __id, __name) \
|
||||
{ \
|
||||
mysqli_object *intern = (mysqli_object *)zend_object_store_get_object(*(__id) TSRMLS_CC);\
|
||||
if (!((__ptr) != (__type)intern->ptr)) {\
|
||||
php_error(E_WARNING, "Couldn' fetch %s", intern->zo.ce->name);\
|
||||
RETURN_NULL();\
|
||||
}\
|
||||
__ptr = (__type)intern->ptr; \
|
||||
}
|
||||
|
||||
#define MYSQLI_CLEAR_RESOURCE(__id) \
|
||||
{ \
|
||||
mysqli_object *intern = (mysqli_object *)zend_object_store_get_object(*(__id) TSRMLS_CC);\
|
||||
intern->ptr = NULL; \
|
||||
}
|
||||
|
||||
#define MYSQLI_STORE_RESULT 0
|
||||
#define MYSQLI_USE_RESULT 1
|
||||
|
||||
/* for mysqli_fetch_assoc */
|
||||
#define MYSQLI_ASSOC 1
|
||||
#define MYSQLI_NUM 2
|
||||
#define MYSQLI_BOTH 3
|
||||
|
||||
/* for mysqli_bind_param */
|
||||
#define MYSQLI_BIND_INT 1
|
||||
#define MYSQLI_BIND_DOUBLE 2
|
||||
#define MYSQLI_BIND_STRING 3
|
||||
#define MYSQLI_BIND_SEND_DATA 4
|
||||
|
||||
/* fetch types */
|
||||
#define FETCH_SIMPLE 0
|
||||
#define FETCH_RESULT 1
|
||||
|
||||
PHP_MYSQLI_API void mysqli_register_link(zval *return_value, void *link TSRMLS_DC);
|
||||
PHP_MYSQLI_API void mysqli_register_stmt(zval *return_value, void *stmt TSRMLS_DC);
|
||||
PHP_MYSQLI_API void mysqli_register_result(zval *return_value, void *result TSRMLS_DC);
|
||||
|
||||
PHP_MINIT_FUNCTION(mysqli);
|
||||
PHP_MSHUTDOWN_FUNCTION(mysqli);
|
||||
PHP_RINIT_FUNCTION(mysqli);
|
||||
PHP_RSHUTDOWN_FUNCTION(mysqli);
|
||||
PHP_MINFO_FUNCTION(mysqli);
|
||||
|
||||
PHP_FUNCTION(mysqli_affected_rows);
|
||||
PHP_FUNCTION(mysqli_autocommit);
|
||||
PHP_FUNCTION(mysqli_bind_param);
|
||||
PHP_FUNCTION(mysqli_bind_result);
|
||||
PHP_FUNCTION(mysqli_change_user);
|
||||
PHP_FUNCTION(mysqli_character_set_name);
|
||||
PHP_FUNCTION(mysqli_close);
|
||||
PHP_FUNCTION(mysqli_commit);
|
||||
PHP_FUNCTION(mysqli_connect);
|
||||
PHP_FUNCTION(mysqli_data_seek);
|
||||
PHP_FUNCTION(mysqli_debug);
|
||||
PHP_FUNCTION(mysqli_disable_reads_from_master);
|
||||
PHP_FUNCTION(mysqli_disable_rpl_parse);
|
||||
PHP_FUNCTION(mysqli_dump_debug_info);
|
||||
PHP_FUNCTION(mysqli_enable_reads_from_master);
|
||||
PHP_FUNCTION(mysqli_enable_rpl_parse);
|
||||
PHP_FUNCTION(mysqli_errno);
|
||||
PHP_FUNCTION(mysqli_error);
|
||||
PHP_FUNCTION(mysqli_execute);
|
||||
PHP_FUNCTION(mysqli_fetch);
|
||||
PHP_FUNCTION(mysqli_fetch_array);
|
||||
PHP_FUNCTION(mysqli_fetch_assoc);
|
||||
PHP_FUNCTION(mysqli_fetch_object);
|
||||
PHP_FUNCTION(mysqli_fetch_field);
|
||||
PHP_FUNCTION(mysqli_fetch_fields);
|
||||
PHP_FUNCTION(mysqli_fetch_field_direct);
|
||||
PHP_FUNCTION(mysqli_fetch_lengths);
|
||||
PHP_FUNCTION(mysqli_fetch_row);
|
||||
PHP_FUNCTION(mysqli_field_count);
|
||||
PHP_FUNCTION(mysqli_field_seek);
|
||||
PHP_FUNCTION(mysqli_field_tell);
|
||||
PHP_FUNCTION(mysqli_free_result);
|
||||
PHP_FUNCTION(mysqli_get_client_info);
|
||||
PHP_FUNCTION(mysqli_get_host_info);
|
||||
PHP_FUNCTION(mysqli_get_proto_info);
|
||||
PHP_FUNCTION(mysqli_get_server_info);
|
||||
PHP_FUNCTION(mysqli_info);
|
||||
PHP_FUNCTION(mysqli_insert_id);
|
||||
PHP_FUNCTION(mysqli_init);
|
||||
PHP_FUNCTION(mysqli_kill);
|
||||
PHP_FUNCTION(mysqli_master_query);
|
||||
PHP_FUNCTION(mysqli_num_fields);
|
||||
PHP_FUNCTION(mysqli_num_rows);
|
||||
PHP_FUNCTION(mysqli_num_warnings);
|
||||
PHP_FUNCTION(mysqli_options);
|
||||
PHP_FUNCTION(mysqli_param_count);
|
||||
PHP_FUNCTION(mysqli_ping);
|
||||
PHP_FUNCTION(mysqli_prepare);
|
||||
PHP_FUNCTION(mysqli_query);
|
||||
PHP_FUNCTION(mysqli_prepare_result);
|
||||
PHP_FUNCTION(mysqli_read_query_result);
|
||||
PHP_FUNCTION(mysqli_real_connect);
|
||||
PHP_FUNCTION(mysqli_real_query);
|
||||
PHP_FUNCTION(mysqli_real_escape_string);
|
||||
PHP_FUNCTION(mysqli_reload);
|
||||
PHP_FUNCTION(mysqli_rollback);
|
||||
PHP_FUNCTION(mysqli_row_seek);
|
||||
PHP_FUNCTION(mysqli_rpl_parse_enabled);
|
||||
PHP_FUNCTION(mysqli_rpl_probe);
|
||||
PHP_FUNCTION(mysqli_rpl_query_type);
|
||||
PHP_FUNCTION(mysqli_select_db);
|
||||
PHP_FUNCTION(mysqli_send_long_data);
|
||||
PHP_FUNCTION(mysqli_send_query);
|
||||
PHP_FUNCTION(mysqli_slave_query);
|
||||
PHP_FUNCTION(mysqli_ssl_set);
|
||||
PHP_FUNCTION(mysqli_stat);
|
||||
PHP_FUNCTION(mysqli_stmt_close);
|
||||
PHP_FUNCTION(mysqli_stmt_errno);
|
||||
PHP_FUNCTION(mysqli_stmt_error);
|
||||
PHP_FUNCTION(mysqli_store_result);
|
||||
PHP_FUNCTION(mysqli_thread_id);
|
||||
PHP_FUNCTION(mysqli_thread_safe);
|
||||
PHP_FUNCTION(mysqli_use_result);
|
||||
PHP_FUNCTION(mysqli_warning_count);
|
||||
|
||||
ZEND_BEGIN_MODULE_GLOBALS(mysqli)
|
||||
long default_link;
|
||||
long num_links;
|
||||
long max_links;
|
||||
unsigned int default_port;
|
||||
char *default_host;
|
||||
char *default_user;
|
||||
char *default_pw;
|
||||
char *default_socket;
|
||||
long error_no;
|
||||
char *error_msg;
|
||||
ZEND_END_MODULE_GLOBALS(mysqli)
|
||||
|
||||
#ifdef ZTS
|
||||
#define MyG(v) TSRMG(mysqli_globals_id, zend_mysqli_globals *, v)
|
||||
#else
|
||||
#define MyG(v) (mysqli_globals.v)
|
||||
#endif
|
||||
|
||||
ZEND_EXTERN_MODULE_GLOBALS(mysqli);
|
||||
|
||||
#endif /* PHP_MYSQLI.H */
|
||||
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
Loading…
Reference in New Issue
Block a user