2003-02-12 08:45:53 +08:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
2014-09-20 00:33:14 +08:00
|
|
|
| PHP Version 7 |
|
2003-02-12 08:45:53 +08:00
|
|
|
+----------------------------------------------------------------------+
|
2015-01-15 23:27:30 +08:00
|
|
|
| Copyright (c) 1997-2015 The PHP Group |
|
2003-02-12 08:45:53 +08:00
|
|
|
+----------------------------------------------------------------------+
|
2006-01-01 20:51:34 +08:00
|
|
|
| This source file is subject to version 3.01 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: |
|
2006-01-01 20:51:34 +08:00
|
|
|
| http://www.php.net/license/3_01.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. |
|
|
|
|
+----------------------------------------------------------------------+
|
2008-03-19 00:57:31 +08:00
|
|
|
| Authors: Georg Richter <georg@php.net> |
|
|
|
|
| Andrey Hristov <andrey@php.net> |
|
|
|
|
| Ulf Wendel <uw@php.net> |
|
2003-02-12 08:45:53 +08:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
|
2010-10-04 18:02:58 +08:00
|
|
|
$Id$
|
2003-02-12 08:45:53 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#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"
|
2011-09-01 04:30:08 +08:00
|
|
|
#include "php_mysqli.h"
|
2007-10-06 05:23:56 +08:00
|
|
|
#include "php_mysqli_structs.h"
|
2010-08-20 20:25:17 +08:00
|
|
|
#include "mysqli_priv.h"
|
2004-02-12 18:43:27 +08:00
|
|
|
#include "zend_exceptions.h"
|
2010-05-18 18:39:26 +08:00
|
|
|
#include "zend_interfaces.h"
|
2003-02-12 08:45:53 +08:00
|
|
|
|
|
|
|
ZEND_DECLARE_MODULE_GLOBALS(mysqli)
|
2006-06-16 02:33:09 +08:00
|
|
|
static PHP_GINIT_FUNCTION(mysqli);
|
|
|
|
|
2014-05-11 14:53:18 +08:00
|
|
|
#define MYSQLI_ADD_PROPERTIES(a, b) \
|
2008-03-19 00:57:31 +08:00
|
|
|
{ \
|
|
|
|
int i = 0; \
|
|
|
|
while (b[i].pname != NULL) { \
|
|
|
|
mysqli_add_property((a), (b)[i].pname, (b)[i].pname_length, \
|
2014-12-14 06:06:14 +08:00
|
|
|
(mysqli_read_t)(b)[i].r_func, (mysqli_write_t)(b)[i].w_func); \
|
2008-03-19 00:57:31 +08:00
|
|
|
i++; \
|
2014-05-11 14:53:18 +08:00
|
|
|
} \
|
2008-03-19 00:57:31 +08:00
|
|
|
}
|
|
|
|
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
static HashTable classes;
|
2014-05-11 14:53:18 +08:00
|
|
|
static zend_object_handlers mysqli_object_handlers;
|
|
|
|
static zend_object_handlers mysqli_object_driver_handlers;
|
|
|
|
static zend_object_handlers mysqli_object_link_handlers;
|
|
|
|
static zend_object_handlers mysqli_object_result_handlers;
|
|
|
|
static zend_object_handlers mysqli_object_stmt_handlers;
|
|
|
|
static zend_object_handlers mysqli_object_warning_handlers;
|
2005-01-07 22:59:59 +08:00
|
|
|
static HashTable mysqli_driver_properties;
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
static HashTable mysqli_link_properties;
|
|
|
|
static HashTable mysqli_result_properties;
|
|
|
|
static HashTable mysqli_stmt_properties;
|
2005-01-07 22:59:59 +08:00
|
|
|
static HashTable mysqli_warning_properties;
|
|
|
|
|
2006-05-09 00:19:43 +08:00
|
|
|
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_driver_class_entry;
|
|
|
|
zend_class_entry *mysqli_warning_class_entry;
|
|
|
|
zend_class_entry *mysqli_exception_class_entry;
|
|
|
|
|
2008-03-19 00:57:31 +08:00
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
typedef zval *(*mysqli_read_t)(mysqli_object *obj, zval *rv);
|
|
|
|
typedef int (*mysqli_write_t)(mysqli_object *obj, zval *newval);
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
|
|
|
|
typedef struct _mysqli_prop_handler {
|
2014-05-11 14:53:18 +08:00
|
|
|
zend_string *name;
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
mysqli_read_t read_func;
|
|
|
|
mysqli_write_t write_func;
|
|
|
|
} mysqli_prop_handler;
|
2003-02-12 08:45:53 +08:00
|
|
|
|
2007-10-06 05:23:56 +08:00
|
|
|
static int le_pmysqli;
|
|
|
|
|
2014-05-11 16:05:14 +08:00
|
|
|
static void free_prop_handler(zval *el) {
|
|
|
|
pefree(Z_PTR_P(el), 1);
|
|
|
|
}
|
2007-10-06 05:23:56 +08:00
|
|
|
|
|
|
|
/* Destructor for mysqli entries in free_links/used_links */
|
|
|
|
void php_mysqli_dtor_p_elements(void *data)
|
|
|
|
{
|
2014-05-11 14:53:18 +08:00
|
|
|
MYSQL *mysql = (MYSQL *)data;
|
2007-11-09 18:56:28 +08:00
|
|
|
mysqli_close(mysql, MYSQLI_CLOSE_IMPLICIT);
|
2007-10-06 05:23:56 +08:00
|
|
|
}
|
|
|
|
|
2008-03-19 00:57:31 +08:00
|
|
|
|
2007-10-06 05:23:56 +08:00
|
|
|
ZEND_RSRC_DTOR_FUNC(php_mysqli_dtor)
|
|
|
|
{
|
2014-05-11 14:53:18 +08:00
|
|
|
if (res->ptr) {
|
|
|
|
mysqli_plist_entry *plist = (mysqli_plist_entry *)res->ptr;
|
2007-11-09 18:56:28 +08:00
|
|
|
zend_ptr_stack_clean(&plist->free_links, php_mysqli_dtor_p_elements, 0);
|
|
|
|
zend_ptr_stack_destroy(&plist->free_links);
|
2007-10-06 05:23:56 +08:00
|
|
|
free(plist);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int php_le_pmysqli(void)
|
|
|
|
{
|
|
|
|
return le_pmysqli;
|
|
|
|
}
|
|
|
|
|
2008-03-11 04:15:38 +08:00
|
|
|
#ifndef MYSQLI_USE_MYSQLND
|
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
|
|
|
for (i=0; i < bbuf.var_cnt; i++) {
|
2004-03-17 05:43:25 +08:00
|
|
|
|
|
|
|
/* free temporary bind buffer */
|
2005-05-05 21:02:32 +08:00
|
|
|
if (type == FETCH_RESULT && bbuf.buf[i].val) {
|
2004-03-18 21:03:17 +08:00
|
|
|
efree(bbuf.buf[i].val);
|
2003-02-12 08:45:53 +08:00
|
|
|
}
|
2004-03-17 05:43:25 +08:00
|
|
|
|
2014-05-11 14:53:18 +08:00
|
|
|
zval_ptr_dtor(&bbuf.vars[i]);
|
2003-07-15 18:37:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (bbuf.vars) {
|
|
|
|
efree(bbuf.vars);
|
|
|
|
}
|
|
|
|
|
2006-05-10 19:53:13 +08:00
|
|
|
/*
|
|
|
|
Don't free bbuf.is_null for FETCH_RESULT since we have allocated
|
|
|
|
is_null and buf in one block so we free only buf, which is the beginning
|
|
|
|
of the block. When FETCH_SIMPLE then buf wasn't allocated together with
|
|
|
|
buf and we have to free it.
|
|
|
|
*/
|
2003-07-15 18:37:19 +08:00
|
|
|
if (type == FETCH_RESULT) {
|
|
|
|
efree(bbuf.buf);
|
2006-05-10 19:53:13 +08:00
|
|
|
} else if (type == FETCH_SIMPLE){
|
|
|
|
efree(bbuf.is_null);
|
2003-02-12 08:45:53 +08:00
|
|
|
}
|
2006-05-10 19:53:13 +08:00
|
|
|
|
2003-07-15 18:37:19 +08:00
|
|
|
bbuf.var_cnt = 0;
|
|
|
|
}
|
|
|
|
/* }}} */
|
2007-10-06 05:23:56 +08:00
|
|
|
#endif
|
2003-07-15 18:37:19 +08:00
|
|
|
|
|
|
|
/* {{{ php_clear_stmt_bind */
|
2014-12-14 06:06:14 +08:00
|
|
|
void php_clear_stmt_bind(MY_STMT *stmt)
|
2003-07-15 18:37:19 +08:00
|
|
|
{
|
|
|
|
if (stmt->stmt) {
|
2007-10-06 05:23:56 +08:00
|
|
|
if (mysqli_stmt_close(stmt->stmt, TRUE)) {
|
2014-12-14 06:06:14 +08:00
|
|
|
php_error_docref(NULL, E_WARNING, "Error occurred while closing statement");
|
2007-10-06 05:23:56 +08:00
|
|
|
return;
|
|
|
|
}
|
2003-07-15 18:37:19 +08:00
|
|
|
}
|
|
|
|
|
2007-10-06 05:23:56 +08:00
|
|
|
/*
|
|
|
|
mysqlnd keeps track of the binding and has freed its
|
|
|
|
structures in stmt_close() above
|
|
|
|
*/
|
2008-03-11 04:15:38 +08:00
|
|
|
#ifndef MYSQLI_USE_MYSQLND
|
2007-10-06 05:23:56 +08:00
|
|
|
/* Clean param bind */
|
2003-07-15 18:37:19 +08:00
|
|
|
php_free_stmt_bind_buffer(stmt->param, FETCH_SIMPLE);
|
2007-10-06 05:23:56 +08:00
|
|
|
/* Clean output bind */
|
2003-07-15 18:37:19 +08:00
|
|
|
php_free_stmt_bind_buffer(stmt->result, FETCH_RESULT);
|
|
|
|
|
2014-05-11 14:53:18 +08:00
|
|
|
if (!Z_ISUNDEF(stmt->link_handle)) {
|
|
|
|
zval_ptr_dtor(&stmt->link_handle);
|
2014-02-27 15:45:16 +08:00
|
|
|
}
|
|
|
|
#endif
|
2004-03-17 05:43:25 +08:00
|
|
|
if (stmt->query) {
|
|
|
|
efree(stmt->query);
|
|
|
|
}
|
2003-02-12 08:45:53 +08:00
|
|
|
efree(stmt);
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2004-06-06 02:31:56 +08:00
|
|
|
/* {{{ php_clear_mysql */
|
|
|
|
void php_clear_mysql(MY_MYSQL *mysql) {
|
2007-10-06 05:23:56 +08:00
|
|
|
if (mysql->hash_key) {
|
2014-08-26 01:24:55 +08:00
|
|
|
zend_string_release(mysql->hash_key);
|
2007-10-06 05:23:56 +08:00
|
|
|
mysql->hash_key = NULL;
|
|
|
|
}
|
2014-05-11 14:53:18 +08:00
|
|
|
if (!Z_ISUNDEF(mysql->li_read)) {
|
2007-10-17 16:18:09 +08:00
|
|
|
zval_ptr_dtor(&(mysql->li_read));
|
2014-05-11 14:53:18 +08:00
|
|
|
ZVAL_UNDEF(&mysql->li_read);
|
2004-06-06 02:31:56 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2006-07-10 20:46:28 +08:00
|
|
|
/* {{{ mysqli_objects_free_storage
|
2003-02-12 08:45:53 +08:00
|
|
|
*/
|
2014-12-14 06:06:14 +08:00
|
|
|
static void mysqli_objects_free_storage(zend_object *object)
|
2005-06-28 01:40:37 +08:00
|
|
|
{
|
2014-05-11 14:53:18 +08:00
|
|
|
mysqli_object *intern = php_mysqli_fetch_object(object);
|
2006-05-30 00:53:56 +08:00
|
|
|
MYSQLI_RESOURCE *my_res = (MYSQLI_RESOURCE *)intern->ptr;
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
|
2007-10-06 05:23:56 +08:00
|
|
|
my_efree(my_res);
|
2014-12-14 06:06:14 +08:00
|
|
|
zend_object_std_dtor(&intern->zo);
|
2006-07-10 20:46:28 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
2006-07-10 18:05:20 +08:00
|
|
|
|
2007-11-09 18:56:28 +08:00
|
|
|
/* mysqli_link_free_storage partly doubles the work of PHP_FUNCTION(mysqli_close) */
|
|
|
|
|
2006-07-10 20:46:28 +08:00
|
|
|
/* {{{ mysqli_link_free_storage
|
|
|
|
*/
|
2014-12-14 06:06:14 +08:00
|
|
|
static void mysqli_link_free_storage(zend_object *object)
|
2006-07-10 20:46:28 +08:00
|
|
|
{
|
2014-05-11 14:53:18 +08:00
|
|
|
mysqli_object *intern = php_mysqli_fetch_object(object);
|
2006-07-10 20:46:28 +08:00
|
|
|
MYSQLI_RESOURCE *my_res = (MYSQLI_RESOURCE *)intern->ptr;
|
|
|
|
|
|
|
|
if (my_res && my_res->ptr) {
|
|
|
|
MY_MYSQL *mysql = (MY_MYSQL *)my_res->ptr;
|
|
|
|
if (mysql->mysql) {
|
2014-12-14 06:06:14 +08:00
|
|
|
php_mysqli_close(mysql, MYSQLI_CLOSE_EXPLICIT, my_res->status);
|
2005-01-07 22:59:59 +08:00
|
|
|
}
|
2006-07-10 20:46:28 +08:00
|
|
|
php_clear_mysql(mysql);
|
|
|
|
efree(mysql);
|
2010-05-13 19:05:09 +08:00
|
|
|
my_res->status = MYSQLI_STATUS_UNKNOWN;
|
2003-02-12 08:45:53 +08:00
|
|
|
}
|
2014-12-14 06:06:14 +08:00
|
|
|
mysqli_objects_free_storage(object);
|
2006-07-10 18:05:20 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2007-10-06 05:23:56 +08:00
|
|
|
/* {{{ mysql_driver_free_storage */
|
2014-12-14 06:06:14 +08:00
|
|
|
static void mysqli_driver_free_storage(zend_object *object)
|
2007-10-06 05:23:56 +08:00
|
|
|
{
|
2014-12-14 06:06:14 +08:00
|
|
|
mysqli_objects_free_storage(object);
|
2007-10-06 05:23:56 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2006-07-10 20:46:28 +08:00
|
|
|
/* {{{ mysqli_stmt_free_storage
|
2006-07-10 18:05:20 +08:00
|
|
|
*/
|
2014-12-14 06:06:14 +08:00
|
|
|
static void mysqli_stmt_free_storage(zend_object *object)
|
2006-07-10 18:05:20 +08:00
|
|
|
{
|
2014-05-11 14:53:18 +08:00
|
|
|
mysqli_object *intern = php_mysqli_fetch_object(object);
|
2006-07-10 18:05:20 +08:00
|
|
|
MYSQLI_RESOURCE *my_res = (MYSQLI_RESOURCE *)intern->ptr;
|
|
|
|
|
2006-07-10 20:46:28 +08:00
|
|
|
if (my_res && my_res->ptr) {
|
|
|
|
MY_STMT *stmt = (MY_STMT *)my_res->ptr;
|
2014-12-14 06:06:14 +08:00
|
|
|
php_clear_stmt_bind(stmt);
|
2006-07-10 20:46:28 +08:00
|
|
|
}
|
2014-12-14 06:06:14 +08:00
|
|
|
mysqli_objects_free_storage(object);
|
2006-07-10 20:46:28 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ mysqli_result_free_storage
|
|
|
|
*/
|
2014-12-14 06:06:14 +08:00
|
|
|
static void mysqli_result_free_storage(zend_object *object)
|
2006-07-10 20:46:28 +08:00
|
|
|
{
|
2014-05-11 14:53:18 +08:00
|
|
|
mysqli_object *intern = php_mysqli_fetch_object(object);
|
2006-07-10 20:46:28 +08:00
|
|
|
MYSQLI_RESOURCE *my_res = (MYSQLI_RESOURCE *)intern->ptr;
|
|
|
|
|
|
|
|
if (my_res && my_res->ptr) {
|
|
|
|
mysql_free_result(my_res->ptr);
|
|
|
|
}
|
2014-12-14 06:06:14 +08:00
|
|
|
mysqli_objects_free_storage(object);
|
2006-07-10 20:46:28 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ mysqli_warning_free_storage
|
|
|
|
*/
|
2014-12-14 06:06:14 +08:00
|
|
|
static void mysqli_warning_free_storage(zend_object *object)
|
2006-07-10 20:46:28 +08:00
|
|
|
{
|
2014-05-11 14:53:18 +08:00
|
|
|
mysqli_object *intern = php_mysqli_fetch_object(object);
|
2006-07-10 20:46:28 +08:00
|
|
|
MYSQLI_RESOURCE *my_res = (MYSQLI_RESOURCE *)intern->ptr;
|
|
|
|
|
|
|
|
if (my_res && my_res->ptr) {
|
|
|
|
php_clear_warnings((MYSQLI_WARNING *)my_res->info);
|
|
|
|
my_res->ptr = NULL;
|
|
|
|
}
|
2014-12-14 06:06:14 +08:00
|
|
|
mysqli_objects_free_storage(object);
|
2003-02-12 08:45:53 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
/* {{{ mysqli_read_na */
|
2014-12-14 06:06:14 +08:00
|
|
|
static zval *mysqli_read_na(mysqli_object *obj, zval *retval)
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
{
|
2014-12-14 06:06:14 +08:00
|
|
|
php_error_docref(NULL, E_ERROR, "Cannot read property");
|
2014-05-11 14:53:18 +08:00
|
|
|
return NULL;
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ mysqli_write_na */
|
2014-12-14 06:06:14 +08:00
|
|
|
static int mysqli_write_na(mysqli_object *obj, zval *newval)
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
{
|
2014-12-14 06:06:14 +08:00
|
|
|
php_error_docref(NULL, E_ERROR, "Cannot write property");
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ mysqli_read_property */
|
2014-12-14 06:06:14 +08:00
|
|
|
zval *mysqli_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv)
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
{
|
|
|
|
zval tmp_member;
|
|
|
|
zval *retval;
|
|
|
|
mysqli_object *obj;
|
2014-05-11 14:53:18 +08:00
|
|
|
mysqli_prop_handler *hnd = NULL;
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
|
2014-05-11 14:53:18 +08:00
|
|
|
obj = Z_MYSQLI_P(object);
|
2003-12-31 16:34:02 +08:00
|
|
|
|
2014-05-11 14:53:18 +08:00
|
|
|
if (Z_TYPE_P(member) != IS_STRING) {
|
2015-06-12 01:41:43 +08:00
|
|
|
ZVAL_COPY(&tmp_member, member);
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
convert_to_string(&tmp_member);
|
|
|
|
member = &tmp_member;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (obj->prop_handler != NULL) {
|
2014-05-11 14:53:18 +08:00
|
|
|
hnd = zend_hash_find_ptr(obj->prop_handler, Z_STR_P(member));
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
}
|
2004-12-04 16:16:04 +08:00
|
|
|
|
2014-05-11 14:53:18 +08:00
|
|
|
if (hnd) {
|
2014-12-14 06:06:14 +08:00
|
|
|
retval = hnd->read_func(obj, rv);
|
2014-05-11 14:53:18 +08:00
|
|
|
if (retval == NULL) {
|
|
|
|
retval = &EG(uninitialized_zval);
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
}
|
|
|
|
} else {
|
2014-05-11 14:53:18 +08:00
|
|
|
zend_object_handlers *std_hnd = zend_get_std_object_handlers();
|
2014-12-14 06:06:14 +08:00
|
|
|
retval = std_hnd->read_property(object, member, type, cache_slot, rv);
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (member == &tmp_member) {
|
|
|
|
zval_dtor(member);
|
|
|
|
}
|
2014-05-11 14:53:18 +08:00
|
|
|
|
|
|
|
return retval;
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2003-12-31 16:34:02 +08:00
|
|
|
/* {{{ mysqli_write_property */
|
2014-12-14 06:06:14 +08:00
|
|
|
void mysqli_write_property(zval *object, zval *member, zval *value, void **cache_slot)
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
{
|
2003-11-24 19:31:26 +08:00
|
|
|
zval tmp_member;
|
|
|
|
mysqli_object *obj;
|
2014-05-11 14:53:18 +08:00
|
|
|
mysqli_prop_handler *hnd = NULL;
|
2003-11-24 19:31:26 +08:00
|
|
|
|
2014-05-11 14:53:18 +08:00
|
|
|
if (Z_TYPE_P(member) != IS_STRING) {
|
2015-06-12 01:41:43 +08:00
|
|
|
ZVAL_COPY(&tmp_member, member);
|
2003-11-24 19:31:26 +08:00
|
|
|
convert_to_string(&tmp_member);
|
|
|
|
member = &tmp_member;
|
|
|
|
}
|
|
|
|
|
2014-05-11 14:53:18 +08:00
|
|
|
obj = Z_MYSQLI_P(object);
|
2003-11-24 19:31:26 +08:00
|
|
|
|
|
|
|
if (obj->prop_handler != NULL) {
|
2014-05-11 14:53:18 +08:00
|
|
|
hnd = zend_hash_find_ptr(obj->prop_handler, Z_STR_P(member));
|
2003-11-24 19:31:26 +08:00
|
|
|
}
|
2014-05-11 14:53:18 +08:00
|
|
|
|
|
|
|
if (hnd) {
|
2014-12-14 06:06:14 +08:00
|
|
|
hnd->write_func(obj, value);
|
2003-11-24 19:31:26 +08:00
|
|
|
} else {
|
2014-05-11 14:53:18 +08:00
|
|
|
zend_object_handlers *std_hnd = zend_get_std_object_handlers();
|
2014-12-14 06:06:14 +08:00
|
|
|
std_hnd->write_property(object, member, value, cache_slot);
|
2003-11-24 19:31:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (member == &tmp_member) {
|
|
|
|
zval_dtor(member);
|
|
|
|
}
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
/* {{{ void mysqli_add_property(HashTable *h, char *pname, mysqli_read_t r_func, mysqli_write_t w_func) */
|
|
|
|
void mysqli_add_property(HashTable *h, const char *pname, size_t pname_len, mysqli_read_t r_func, mysqli_write_t w_func) {
|
2014-05-11 14:53:18 +08:00
|
|
|
mysqli_prop_handler p;
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
|
2014-08-26 01:24:55 +08:00
|
|
|
p.name = zend_string_init(pname, pname_len, 1);
|
2010-10-04 18:02:58 +08:00
|
|
|
p.read_func = (r_func) ? r_func : mysqli_read_na;
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
p.write_func = (w_func) ? w_func : mysqli_write_na;
|
2014-05-11 14:53:18 +08:00
|
|
|
zend_hash_add_mem(h, p.name, &p, sizeof(mysqli_prop_handler));
|
2014-08-26 01:24:55 +08:00
|
|
|
zend_string_release(p.name);
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
}
|
2003-12-13 08:28:21 +08:00
|
|
|
/* }}} */
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
static int mysqli_object_has_property(zval *object, zval *member, int has_set_exists, void **cache_slot) /* {{{ */
|
2008-03-19 00:57:31 +08:00
|
|
|
{
|
2014-05-11 14:53:18 +08:00
|
|
|
mysqli_object *obj = Z_MYSQLI_P(object);
|
|
|
|
mysqli_prop_handler *p;
|
2008-03-19 00:57:31 +08:00
|
|
|
int ret = 0;
|
|
|
|
|
2014-05-11 14:53:18 +08:00
|
|
|
if ((p = zend_hash_find_ptr(obj->prop_handler, Z_STR_P(member))) != NULL) {
|
2008-03-19 00:57:31 +08:00
|
|
|
switch (has_set_exists) {
|
|
|
|
case 2:
|
|
|
|
ret = 1;
|
|
|
|
break;
|
|
|
|
case 1: {
|
2014-05-11 14:53:18 +08:00
|
|
|
zval rv;
|
2014-12-14 06:06:14 +08:00
|
|
|
zval *value = mysqli_read_property(object, member, BP_VAR_IS, cache_slot, &rv);
|
2014-05-11 14:53:18 +08:00
|
|
|
if (value != &EG(uninitialized_zval)) {
|
2008-03-19 00:57:31 +08:00
|
|
|
convert_to_boolean(value);
|
2014-04-30 22:32:42 +08:00
|
|
|
ret = Z_TYPE_P(value) == IS_TRUE ? 1 : 0;
|
2008-03-19 00:57:31 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 0:{
|
2014-05-11 14:53:18 +08:00
|
|
|
zval rv;
|
2014-12-14 06:06:14 +08:00
|
|
|
zval *value = mysqli_read_property(object, member, BP_VAR_IS, cache_slot, &rv);
|
2014-05-11 14:53:18 +08:00
|
|
|
if (value != &EG(uninitialized_zval)) {
|
|
|
|
ret = Z_TYPE_P(value) != IS_NULL? 1 : 0;
|
|
|
|
zval_ptr_dtor(value);
|
2008-03-19 00:57:31 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2014-12-14 06:06:14 +08:00
|
|
|
php_error_docref(NULL, E_WARNING, "Invalid value for has_set_exists");
|
2008-03-19 00:57:31 +08:00
|
|
|
}
|
2009-08-27 20:41:14 +08:00
|
|
|
} else {
|
2014-05-11 14:53:18 +08:00
|
|
|
zend_object_handlers *std_hnd = zend_get_std_object_handlers();
|
2014-12-14 06:06:14 +08:00
|
|
|
ret = std_hnd->has_property(object, member, has_set_exists, cache_slot);
|
2008-03-19 00:57:31 +08:00
|
|
|
}
|
2014-05-11 14:53:18 +08:00
|
|
|
|
2008-03-19 00:57:31 +08:00
|
|
|
return ret;
|
|
|
|
} /* }}} */
|
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
HashTable *mysqli_object_get_debug_info(zval *object, int *is_temp)
|
2008-03-19 00:57:31 +08:00
|
|
|
{
|
2014-05-11 14:53:18 +08:00
|
|
|
mysqli_object *obj = Z_MYSQLI_P(object);
|
2008-03-19 00:57:31 +08:00
|
|
|
HashTable *retval, *props = obj->prop_handler;
|
|
|
|
mysqli_prop_handler *entry;
|
|
|
|
|
|
|
|
ALLOC_HASHTABLE(retval);
|
|
|
|
ZEND_INIT_SYMTABLE_EX(retval, zend_hash_num_elements(props) + 1, 0);
|
|
|
|
|
2014-05-11 14:53:18 +08:00
|
|
|
ZEND_HASH_FOREACH_PTR(props, entry) {
|
|
|
|
zval rv, member;
|
2008-03-19 00:57:31 +08:00
|
|
|
zval *value;
|
2014-05-11 14:53:18 +08:00
|
|
|
ZVAL_STR(&member, entry->name);
|
2014-12-14 06:06:14 +08:00
|
|
|
value = mysqli_read_property(object, &member, BP_VAR_IS, 0, &rv);
|
2014-05-11 14:53:18 +08:00
|
|
|
if (value != &EG(uninitialized_zval)) {
|
|
|
|
zend_hash_add(retval, Z_STR(member), value);
|
2008-03-19 00:57:31 +08:00
|
|
|
}
|
2014-05-11 14:53:18 +08:00
|
|
|
} ZEND_HASH_FOREACH_END();
|
2008-03-19 00:57:31 +08:00
|
|
|
|
|
|
|
*is_temp = 1;
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2003-02-12 08:45:53 +08:00
|
|
|
/* {{{ mysqli_objects_new
|
|
|
|
*/
|
2014-12-14 06:06:14 +08:00
|
|
|
PHP_MYSQLI_EXPORT(zend_object *) mysqli_objects_new(zend_class_entry *class_type)
|
2003-02-12 08:45:53 +08:00
|
|
|
{
|
|
|
|
mysqli_object *intern;
|
2004-12-03 15:56:19 +08:00
|
|
|
zend_class_entry *mysqli_base_class;
|
2014-05-11 14:53:18 +08:00
|
|
|
zend_object_handlers *handlers;
|
2003-02-12 08:45:53 +08:00
|
|
|
|
2015-02-04 20:24:13 +08:00
|
|
|
intern = ecalloc(1, sizeof(mysqli_object) + zend_object_properties_size(class_type));
|
2004-12-03 15:56:19 +08:00
|
|
|
|
|
|
|
mysqli_base_class = class_type;
|
2008-03-19 00:57:31 +08:00
|
|
|
while (mysqli_base_class->type != ZEND_INTERNAL_CLASS &&
|
|
|
|
mysqli_base_class->parent != NULL) {
|
2004-12-03 15:56:19 +08:00
|
|
|
mysqli_base_class = mysqli_base_class->parent;
|
2004-06-06 02:31:56 +08:00
|
|
|
}
|
2014-05-11 14:53:18 +08:00
|
|
|
intern->prop_handler = zend_hash_find_ptr(&classes, mysqli_base_class->name);
|
2003-02-12 08:45:53 +08:00
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
zend_object_std_init(&intern->zo, class_type);
|
2010-05-24 22:11:39 +08:00
|
|
|
object_properties_init(&intern->zo, class_type);
|
2003-02-12 08:45:53 +08:00
|
|
|
|
2006-07-10 20:46:28 +08:00
|
|
|
/* link object */
|
2014-12-14 06:06:14 +08:00
|
|
|
if (instanceof_function(class_type, mysqli_link_class_entry)) {
|
2014-05-11 14:53:18 +08:00
|
|
|
handlers = &mysqli_object_link_handlers;
|
2014-12-14 06:06:14 +08:00
|
|
|
} else if (instanceof_function(class_type, mysqli_driver_class_entry)) { /* driver object */
|
2014-05-11 14:53:18 +08:00
|
|
|
handlers = &mysqli_object_driver_handlers;
|
2014-12-14 06:06:14 +08:00
|
|
|
} else if (instanceof_function(class_type, mysqli_stmt_class_entry)) { /* stmt object */
|
2014-05-11 14:53:18 +08:00
|
|
|
handlers = &mysqli_object_stmt_handlers;
|
2014-12-14 06:06:14 +08:00
|
|
|
} else if (instanceof_function(class_type, mysqli_result_class_entry)) { /* result object */
|
2014-05-11 14:53:18 +08:00
|
|
|
handlers = &mysqli_object_result_handlers;
|
2014-12-14 06:06:14 +08:00
|
|
|
} else if (instanceof_function(class_type, mysqli_warning_class_entry)) { /* warning object */
|
2014-05-11 14:53:18 +08:00
|
|
|
handlers = &mysqli_object_warning_handlers;
|
2006-07-10 20:46:28 +08:00
|
|
|
} else {
|
2014-05-11 14:53:18 +08:00
|
|
|
handlers = &mysqli_object_handlers;
|
2006-07-10 20:46:28 +08:00
|
|
|
}
|
|
|
|
|
2014-05-11 17:02:08 +08:00
|
|
|
intern->zo.handlers = handlers;
|
2003-02-12 08:45:53 +08:00
|
|
|
|
2014-05-11 14:53:18 +08:00
|
|
|
return &intern->zo;
|
2003-02-12 08:45:53 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
2007-10-06 05:23:56 +08:00
|
|
|
|
2011-09-01 04:30:08 +08:00
|
|
|
#ifdef MYSQLI_USE_MYSQLND
|
2011-10-26 07:01:49 +08:00
|
|
|
#include "ext/mysqlnd/mysqlnd_reverse_api.h"
|
2014-12-14 06:06:14 +08:00
|
|
|
static MYSQLND *mysqli_convert_zv_to_mysqlnd(zval * zv)
|
2011-09-01 04:30:08 +08:00
|
|
|
{
|
2014-12-14 06:06:14 +08:00
|
|
|
if (Z_TYPE_P(zv) == IS_OBJECT && instanceof_function(Z_OBJCE_P(zv), mysqli_link_class_entry)) {
|
2014-05-11 14:53:18 +08:00
|
|
|
MY_MYSQL *mysql;
|
|
|
|
MYSQLI_RESOURCE *my_res;
|
|
|
|
mysqli_object *intern = Z_MYSQLI_P(zv);
|
2011-09-01 04:30:08 +08:00
|
|
|
if (!(my_res = (MYSQLI_RESOURCE *)intern->ptr)) {
|
|
|
|
/* We know that we have a mysqli object, so this failure should be emitted */
|
2015-06-30 09:05:24 +08:00
|
|
|
php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", ZSTR_VAL(intern->zo.ce->name));
|
2011-09-01 04:30:08 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
2011-09-21 20:34:15 +08:00
|
|
|
mysql = (MY_MYSQL *)(my_res->ptr);
|
2011-09-01 04:30:08 +08:00
|
|
|
return mysql ? mysql->mysql : NULL;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-10-19 23:04:12 +08:00
|
|
|
static MYSQLND_REVERSE_API mysqli_reverse_api = {
|
2011-09-01 04:30:08 +08:00
|
|
|
&mysqli_module_entry,
|
|
|
|
mysqli_convert_zv_to_mysqlnd
|
|
|
|
};
|
|
|
|
#endif
|
2007-10-06 05:23:56 +08:00
|
|
|
|
2003-02-12 08:45:53 +08:00
|
|
|
/* {{{ 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)
|
2007-10-06 05:23:56 +08:00
|
|
|
STD_PHP_INI_ENTRY_EX("mysqli.max_persistent", "-1", PHP_INI_SYSTEM, OnUpdateLong, max_persistent, zend_mysqli_globals, mysqli_globals, display_link_numbers)
|
|
|
|
STD_PHP_INI_BOOLEAN("mysqli.allow_persistent", "1", PHP_INI_SYSTEM, OnUpdateLong, allow_persistent, zend_mysqli_globals, mysqli_globals)
|
2014-01-29 21:27:43 +08:00
|
|
|
STD_PHP_INI_BOOLEAN("mysqli.rollback_on_cached_plink", "0",PHP_INI_SYSTEM, OnUpdateBool, rollback_on_cached_plink, zend_mysqli_globals, mysqli_globals)
|
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)
|
2008-07-21 20:58:51 +08:00
|
|
|
#ifdef PHP_MYSQL_UNIX_SOCK_ADDR
|
|
|
|
STD_PHP_INI_ENTRY("mysqli.default_socket", MYSQL_UNIX_ADDR,PHP_INI_ALL,OnUpdateStringUnempty, default_socket, zend_mysqli_globals, mysqli_globals)
|
|
|
|
#else
|
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)
|
2008-07-21 20:58:51 +08:00
|
|
|
#endif
|
2004-02-26 19:40:35 +08:00
|
|
|
STD_PHP_INI_BOOLEAN("mysqli.reconnect", "0", PHP_INI_SYSTEM, OnUpdateLong, reconnect, zend_mysqli_globals, mysqli_globals)
|
2007-10-06 05:23:56 +08:00
|
|
|
STD_PHP_INI_BOOLEAN("mysqli.allow_local_infile", "1", PHP_INI_SYSTEM, OnUpdateLong, allow_local_infile, zend_mysqli_globals, mysqli_globals)
|
2003-02-12 08:45:53 +08:00
|
|
|
PHP_INI_END()
|
|
|
|
/* }}} */
|
|
|
|
|
2006-06-16 02:33:09 +08:00
|
|
|
/* {{{ PHP_GINIT_FUNCTION
|
2003-02-12 08:45:53 +08:00
|
|
|
*/
|
2006-06-16 02:33:09 +08:00
|
|
|
static PHP_GINIT_FUNCTION(mysqli)
|
2003-02-12 08:45:53 +08:00
|
|
|
{
|
2014-10-15 18:08:25 +08:00
|
|
|
#if defined(COMPILE_DL_MYSQLI) && defined(ZTS)
|
2015-02-17 00:19:32 +08:00
|
|
|
ZEND_TSRMLS_CACHE_UPDATE();
|
2014-10-15 18:08:25 +08:00
|
|
|
#endif
|
2003-02-12 08:45:53 +08:00
|
|
|
mysqli_globals->num_links = 0;
|
2007-10-06 05:23:56 +08:00
|
|
|
mysqli_globals->num_active_persistent = 0;
|
|
|
|
mysqli_globals->num_inactive_persistent = 0;
|
|
|
|
mysqli_globals->max_links = -1;
|
|
|
|
mysqli_globals->max_persistent = -1;
|
|
|
|
mysqli_globals->allow_persistent = 1;
|
2003-02-12 08:45:53 +08:00
|
|
|
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;
|
2004-02-26 19:40:35 +08:00
|
|
|
mysqli_globals->reconnect = 0;
|
2003-12-13 08:28:21 +08:00
|
|
|
mysqli_globals->report_mode = 0;
|
|
|
|
mysqli_globals->report_ht = 0;
|
2007-10-06 05:23:56 +08:00
|
|
|
mysqli_globals->allow_local_infile = 1;
|
2005-01-07 22:59:59 +08:00
|
|
|
#ifdef HAVE_EMBEDDED_MYSQLI
|
|
|
|
mysqli_globals->embedded = 1;
|
|
|
|
#else
|
|
|
|
mysqli_globals->embedded = 0;
|
|
|
|
#endif
|
2014-01-29 21:27:43 +08:00
|
|
|
mysqli_globals->rollback_on_cached_plink = FALSE;
|
2003-02-12 08:45:53 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ PHP_MINIT_FUNCTION
|
|
|
|
*/
|
|
|
|
PHP_MINIT_FUNCTION(mysqli)
|
|
|
|
{
|
2005-01-07 22:59:59 +08:00
|
|
|
zend_class_entry *ce,cex;
|
2004-12-26 00:42:53 +08:00
|
|
|
zend_object_handlers *std_hnd = zend_get_std_object_handlers();
|
2010-10-04 18:02:58 +08:00
|
|
|
|
2003-02-12 08:45:53 +08:00
|
|
|
REGISTER_INI_ENTRIES();
|
2008-03-11 04:15:38 +08:00
|
|
|
#ifndef MYSQLI_USE_MYSQLND
|
2007-10-06 05:23:56 +08:00
|
|
|
#if MYSQL_VERSION_ID >= 40000
|
|
|
|
if (mysql_server_init(0, NULL, NULL)) {
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
2003-02-12 08:45:53 +08:00
|
|
|
|
|
|
|
memcpy(&mysqli_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
|
2014-05-11 14:53:18 +08:00
|
|
|
mysqli_object_handlers.offset = XtOffsetOf(mysqli_object, zo);
|
|
|
|
mysqli_object_handlers.free_obj = mysqli_objects_free_storage;
|
2004-06-06 02:31:56 +08:00
|
|
|
mysqli_object_handlers.clone_obj = NULL;
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
mysqli_object_handlers.read_property = mysqli_read_property;
|
|
|
|
mysqli_object_handlers.write_property = mysqli_write_property;
|
2004-12-26 00:42:53 +08:00
|
|
|
mysqli_object_handlers.get_property_ptr_ptr = std_hnd->get_property_ptr_ptr;
|
2008-03-19 00:57:31 +08:00
|
|
|
mysqli_object_handlers.has_property = mysqli_object_has_property;
|
2014-08-16 16:44:02 +08:00
|
|
|
#if PHP_VERSION_ID >= 50300
|
2008-03-19 00:57:31 +08:00
|
|
|
mysqli_object_handlers.get_debug_info = mysqli_object_get_debug_info;
|
2008-05-07 01:05:14 +08:00
|
|
|
#endif
|
2014-05-11 14:53:18 +08:00
|
|
|
memcpy(&mysqli_object_driver_handlers, &mysqli_object_handlers, sizeof(zend_object_handlers));
|
|
|
|
mysqli_object_driver_handlers.free_obj = mysqli_driver_free_storage;
|
|
|
|
memcpy(&mysqli_object_link_handlers, &mysqli_object_handlers, sizeof(zend_object_handlers));
|
|
|
|
mysqli_object_link_handlers.free_obj = mysqli_link_free_storage;
|
|
|
|
memcpy(&mysqli_object_result_handlers, &mysqli_object_handlers, sizeof(zend_object_handlers));
|
|
|
|
mysqli_object_result_handlers.free_obj = mysqli_result_free_storage;
|
|
|
|
memcpy(&mysqli_object_stmt_handlers, &mysqli_object_handlers, sizeof(zend_object_handlers));
|
|
|
|
mysqli_object_stmt_handlers.free_obj = mysqli_stmt_free_storage;
|
|
|
|
memcpy(&mysqli_object_warning_handlers, &mysqli_object_handlers, sizeof(zend_object_handlers));
|
|
|
|
mysqli_object_warning_handlers.free_obj = mysqli_warning_free_storage;
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
|
|
|
|
zend_hash_init(&classes, 0, NULL, NULL, 1);
|
2003-02-12 08:45:53 +08:00
|
|
|
|
2007-10-06 05:23:56 +08:00
|
|
|
/* persistent connections */
|
|
|
|
le_pmysqli = zend_register_list_destructors_ex(NULL, php_mysqli_dtor,
|
|
|
|
"MySqli persistent connection", module_number);
|
|
|
|
|
2005-01-07 22:59:59 +08:00
|
|
|
INIT_CLASS_ENTRY(cex, "mysqli_sql_exception", mysqli_exception_methods);
|
|
|
|
#ifdef HAVE_SPL
|
2014-12-14 06:06:14 +08:00
|
|
|
mysqli_exception_class_entry = zend_register_internal_class_ex(&cex, spl_ce_RuntimeException);
|
2005-01-07 22:59:59 +08:00
|
|
|
#else
|
2015-07-03 22:45:03 +08:00
|
|
|
mysqli_exception_class_entry = zend_register_internal_class_ex(&cex, zend_ce_exception);
|
2005-01-07 22:59:59 +08:00
|
|
|
#endif
|
|
|
|
mysqli_exception_class_entry->ce_flags |= ZEND_ACC_FINAL;
|
2014-12-14 06:06:14 +08:00
|
|
|
zend_declare_property_long(mysqli_exception_class_entry, "code", sizeof("code")-1, 0, ZEND_ACC_PROTECTED);
|
|
|
|
zend_declare_property_string(mysqli_exception_class_entry, "sqlstate", sizeof("sqlstate")-1, "00000", ZEND_ACC_PROTECTED);
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
|
2005-01-07 22:59:59 +08:00
|
|
|
REGISTER_MYSQLI_CLASS_ENTRY("mysqli_driver", mysqli_driver_class_entry, mysqli_driver_methods);
|
|
|
|
ce = mysqli_driver_class_entry;
|
2014-05-11 16:05:14 +08:00
|
|
|
zend_hash_init(&mysqli_driver_properties, 0, NULL, free_prop_handler, 1);
|
2005-01-07 22:59:59 +08:00
|
|
|
MYSQLI_ADD_PROPERTIES(&mysqli_driver_properties, mysqli_driver_property_entries);
|
2014-12-14 06:06:14 +08:00
|
|
|
zend_declare_property_null(ce, "client_info", sizeof("client_info") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "client_version", sizeof("client_version") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "driver_version", sizeof("driver_version") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "embedded", sizeof("embedded") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "reconnect", sizeof("reconnect") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "report_mode", sizeof("report_mode") - 1, ZEND_ACC_PUBLIC);
|
2014-11-22 12:57:55 +08:00
|
|
|
ce->ce_flags |= ZEND_ACC_FINAL;
|
2014-05-11 14:53:18 +08:00
|
|
|
zend_hash_add_ptr(&classes, ce->name, &mysqli_driver_properties);
|
2005-01-07 22:59:59 +08:00
|
|
|
|
|
|
|
REGISTER_MYSQLI_CLASS_ENTRY("mysqli", mysqli_link_class_entry, mysqli_link_methods);
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
ce = mysqli_link_class_entry;
|
2014-05-11 16:05:14 +08:00
|
|
|
zend_hash_init(&mysqli_link_properties, 0, NULL, free_prop_handler, 1);
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
MYSQLI_ADD_PROPERTIES(&mysqli_link_properties, mysqli_link_property_entries);
|
2014-12-14 06:06:14 +08:00
|
|
|
zend_declare_property_null(ce, "affected_rows", sizeof("affected_rows") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "client_info", sizeof("client_info") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "client_version", sizeof("client_version") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "connect_errno", sizeof("connect_errno") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "connect_error", sizeof("connect_error") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "errno", sizeof("errno") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "error", sizeof("error") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "error_list", sizeof("error_list") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "field_count", sizeof("field_count") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "host_info", sizeof("host_info") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "info", sizeof("info") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "insert_id", sizeof("insert_id") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "server_info", sizeof("server_info") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "server_version", sizeof("server_version") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "stat", sizeof("stat") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "sqlstate", sizeof("sqlstate") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "protocol_version", sizeof("protocol_version") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "thread_id", sizeof("thread_id") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "warning_count", sizeof("warning_count") - 1, ZEND_ACC_PUBLIC);
|
2014-05-11 14:53:18 +08:00
|
|
|
zend_hash_add_ptr(&classes, ce->name, &mysqli_link_properties);
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
|
2005-01-07 22:59:59 +08:00
|
|
|
REGISTER_MYSQLI_CLASS_ENTRY("mysqli_warning", mysqli_warning_class_entry, mysqli_warning_methods);
|
|
|
|
ce = mysqli_warning_class_entry;
|
2014-11-22 12:57:55 +08:00
|
|
|
ce->ce_flags |= ZEND_ACC_FINAL;
|
2014-05-11 16:05:14 +08:00
|
|
|
zend_hash_init(&mysqli_warning_properties, 0, NULL, free_prop_handler, 1);
|
2005-01-07 22:59:59 +08:00
|
|
|
MYSQLI_ADD_PROPERTIES(&mysqli_warning_properties, mysqli_warning_property_entries);
|
2014-12-14 06:06:14 +08:00
|
|
|
zend_declare_property_null(ce, "message", sizeof("message") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "sqlstate", sizeof("sqlstate") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "errno", sizeof("errno") - 1, ZEND_ACC_PUBLIC);
|
2014-05-11 14:53:18 +08:00
|
|
|
zend_hash_add_ptr(&classes, ce->name, &mysqli_warning_properties);
|
2005-01-07 22:59:59 +08:00
|
|
|
|
2003-02-12 08:45:53 +08:00
|
|
|
REGISTER_MYSQLI_CLASS_ENTRY("mysqli_result", mysqli_result_class_entry, mysqli_result_methods);
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
ce = mysqli_result_class_entry;
|
2014-05-11 16:05:14 +08:00
|
|
|
zend_hash_init(&mysqli_result_properties, 0, NULL, free_prop_handler, 1);
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
MYSQLI_ADD_PROPERTIES(&mysqli_result_properties, mysqli_result_property_entries);
|
2014-12-14 06:06:14 +08:00
|
|
|
zend_declare_property_null(ce, "current_field", sizeof("current_field") - 1,ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "field_count", sizeof("field_count") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "lengths", sizeof("lengths") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "num_rows", sizeof("num_rows") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "type", sizeof("type") - 1, ZEND_ACC_PUBLIC);
|
2010-05-18 18:39:26 +08:00
|
|
|
mysqli_result_class_entry->get_iterator = php_mysqli_result_get_iterator;
|
|
|
|
mysqli_result_class_entry->iterator_funcs.funcs = &php_mysqli_result_iterator_funcs;
|
2014-12-14 06:06:14 +08:00
|
|
|
zend_class_implements(mysqli_result_class_entry, 1, zend_ce_traversable);
|
2014-05-11 14:53:18 +08:00
|
|
|
zend_hash_add_ptr(&classes, ce->name, &mysqli_result_properties);
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
|
2003-02-12 08:45:53 +08:00
|
|
|
REGISTER_MYSQLI_CLASS_ENTRY("mysqli_stmt", mysqli_stmt_class_entry, mysqli_stmt_methods);
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
ce = mysqli_stmt_class_entry;
|
2014-05-11 16:05:14 +08:00
|
|
|
zend_hash_init(&mysqli_stmt_properties, 0, NULL, free_prop_handler, 1);
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
MYSQLI_ADD_PROPERTIES(&mysqli_stmt_properties, mysqli_stmt_property_entries);
|
2014-12-14 06:06:14 +08:00
|
|
|
zend_declare_property_null(ce, "affected_rows", sizeof("affected_rows") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "insert_id", sizeof("insert_id") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "num_rows", sizeof("num_rows") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "param_count", sizeof("param_count") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "field_count", sizeof("field_count") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "errno", sizeof("errno") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "error", sizeof("error") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "error_list", sizeof("error_list") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "sqlstate", sizeof("sqlstate") - 1, ZEND_ACC_PUBLIC);
|
|
|
|
zend_declare_property_null(ce, "id", sizeof("id") - 1, ZEND_ACC_PUBLIC);
|
2014-05-11 14:53:18 +08:00
|
|
|
zend_hash_add_ptr(&classes, ce->name, &mysqli_stmt_properties);
|
2010-10-04 18:02:58 +08:00
|
|
|
|
2003-02-12 08:45:53 +08:00
|
|
|
/* mysqli_options */
|
2014-08-26 01:24:55 +08:00
|
|
|
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);
|
2008-03-11 04:15:38 +08:00
|
|
|
#if defined(MYSQLI_USE_MYSQLND)
|
2014-08-26 01:24:55 +08:00
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_OPT_NET_CMD_BUFFER_SIZE", MYSQLND_OPT_NET_CMD_BUFFER_SIZE, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_OPT_NET_READ_BUFFER_SIZE", MYSQLND_OPT_NET_READ_BUFFER_SIZE, CONST_CS | CONST_PERSISTENT);
|
2007-10-06 05:23:56 +08:00
|
|
|
#endif
|
|
|
|
#ifdef MYSQLND_STRING_TO_INT_CONVERSION
|
2014-08-26 01:24:55 +08:00
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_OPT_INT_AND_FLOAT_NATIVE", MYSQLND_OPT_INT_AND_FLOAT_NATIVE, CONST_CS | CONST_PERSISTENT);
|
2007-10-06 05:23:56 +08:00
|
|
|
#endif
|
2010-08-31 00:59:10 +08:00
|
|
|
#if MYSQL_VERSION_ID > 50110 || defined(MYSQLI_USE_MYSQLND)
|
2014-08-26 01:24:55 +08:00
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_OPT_SSL_VERIFY_SERVER_CERT", MYSQL_OPT_SSL_VERIFY_SERVER_CERT, CONST_CS | CONST_PERSISTENT);
|
2010-08-31 00:59:10 +08:00
|
|
|
#endif
|
2003-02-12 08:45:53 +08:00
|
|
|
|
2012-10-03 20:14:59 +08:00
|
|
|
#if MYSQL_VERSION_ID > 50605 || defined(MYSQLI_USE_MYSQLND)
|
2014-08-26 01:24:55 +08:00
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_SERVER_PUBLIC_KEY", MYSQL_SERVER_PUBLIC_KEY, CONST_CS | CONST_PERSISTENT);
|
2012-10-03 20:14:59 +08:00
|
|
|
#endif
|
2012-09-26 00:26:02 +08:00
|
|
|
|
2010-10-04 18:02:58 +08:00
|
|
|
/* mysqli_real_connect flags */
|
2014-08-26 01:24:55 +08:00
|
|
|
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_FOUND_ROWS", CLIENT_FOUND_ROWS, CONST_CS | CONST_PERSISTENT);
|
2014-07-17 00:24:39 +08:00
|
|
|
#if (MYSQL_VERSION_ID >= 50611 && defined(CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS)) || defined(MYSQLI_USE_MYSQLND)
|
2014-08-26 01:24:55 +08:00
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS", CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_OPT_CAN_HANDLE_EXPIRED_PASSWORDS", MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, CONST_CS | CONST_PERSISTENT);
|
2014-07-17 00:24:39 +08:00
|
|
|
#endif
|
2003-02-12 08:45:53 +08:00
|
|
|
|
|
|
|
/* for mysqli_query */
|
2014-08-26 01:24:55 +08:00
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_STORE_RESULT", MYSQLI_STORE_RESULT, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_USE_RESULT", MYSQLI_USE_RESULT, CONST_CS | CONST_PERSISTENT);
|
2008-11-19 01:02:18 +08:00
|
|
|
#if defined (MYSQLI_USE_MYSQLND)
|
2014-08-26 01:24:55 +08:00
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_ASYNC", MYSQLI_ASYNC, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_STORE_RESULT_COPY_DATA", MYSQLI_STORE_RESULT_COPY_DATA, CONST_CS | CONST_PERSISTENT);
|
2008-11-19 01:02:18 +08:00
|
|
|
#endif
|
2003-02-12 08:45:53 +08:00
|
|
|
|
|
|
|
/* for mysqli_fetch_assoc */
|
2014-08-26 01:24:55 +08:00
|
|
|
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);
|
2010-10-04 18:02:58 +08:00
|
|
|
|
2004-07-07 16:02:27 +08:00
|
|
|
/* for mysqli_stmt_set_attr */
|
2014-08-26 01:24:55 +08:00
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH", STMT_ATTR_UPDATE_MAX_LENGTH, CONST_CS | CONST_PERSISTENT);
|
2004-07-23 20:47:36 +08:00
|
|
|
|
2008-03-11 04:15:38 +08:00
|
|
|
#if MYSQL_VERSION_ID > 50003 || defined(MYSQLI_USE_MYSQLND)
|
2014-08-26 01:24:55 +08:00
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_STMT_ATTR_CURSOR_TYPE", STMT_ATTR_CURSOR_TYPE, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_CURSOR_TYPE_NO_CURSOR", CURSOR_TYPE_NO_CURSOR, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_CURSOR_TYPE_READ_ONLY", CURSOR_TYPE_READ_ONLY, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_CURSOR_TYPE_FOR_UPDATE", CURSOR_TYPE_FOR_UPDATE, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_CURSOR_TYPE_SCROLLABLE", CURSOR_TYPE_SCROLLABLE, CONST_CS | CONST_PERSISTENT);
|
2004-07-23 20:47:36 +08:00
|
|
|
#endif
|
2005-06-22 17:12:43 +08:00
|
|
|
|
2008-03-11 04:15:38 +08:00
|
|
|
#if MYSQL_VERSION_ID > 50007 || defined(MYSQLI_USE_MYSQLND)
|
2014-08-26 01:24:55 +08:00
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_STMT_ATTR_PREFETCH_ROWS", STMT_ATTR_PREFETCH_ROWS, CONST_CS | CONST_PERSISTENT);
|
2005-06-22 17:12:43 +08:00
|
|
|
#endif
|
2010-10-04 18:02:58 +08:00
|
|
|
|
2003-02-12 08:45:53 +08:00
|
|
|
/* column information */
|
2014-08-26 01:24:55 +08:00
|
|
|
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_ENUM_FLAG", ENUM_FLAG, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_BINARY_FLAG", BINARY_FLAG, CONST_CS | CONST_PERSISTENT);
|
2008-03-11 04:15:38 +08:00
|
|
|
#if MYSQL_VERSION_ID > 50001 || defined(MYSQLI_USE_MYSQLND)
|
2014-08-26 01:24:55 +08:00
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_NO_DEFAULT_VALUE_FLAG", NO_DEFAULT_VALUE_FLAG, CONST_CS | CONST_PERSISTENT);
|
2008-03-10 21:39:53 +08:00
|
|
|
#endif
|
2008-02-12 00:44:48 +08:00
|
|
|
|
2008-03-11 04:15:38 +08:00
|
|
|
#if (MYSQL_VERSION_ID > 51122 && MYSQL_VERSION_ID < 60000) || (MYSQL_VERSION_ID > 60003) || defined(MYSQLI_USE_MYSQLND)
|
2014-08-26 01:24:55 +08:00
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_ON_UPDATE_NOW_FLAG", ON_UPDATE_NOW_FLAG, CONST_CS | CONST_PERSISTENT);
|
2008-02-12 00:44:48 +08:00
|
|
|
#endif
|
2003-02-12 08:45:53 +08:00
|
|
|
|
2014-08-26 01:24:55 +08:00
|
|
|
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_FLOAT", 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);
|
2015-09-30 15:02:11 +08:00
|
|
|
#ifdef FIELD_TYPE_JSON
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_JSON", FIELD_TYPE_JSON, CONST_CS | CONST_PERSISTENT);
|
|
|
|
#endif
|
2008-03-11 04:15:38 +08:00
|
|
|
#if MYSQL_VERSION_ID > 50002 || defined(MYSQLI_USE_MYSQLND)
|
2014-08-26 01:24:55 +08:00
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_NEWDECIMAL", FIELD_TYPE_NEWDECIMAL, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_BIT", FIELD_TYPE_BIT, CONST_CS | CONST_PERSISTENT);
|
2006-01-14 22:15:41 +08:00
|
|
|
#endif
|
|
|
|
|
2014-08-26 01:24:55 +08:00
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_SET_CHARSET_NAME", MYSQL_SET_CHARSET_NAME, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_SET_CHARSET_DIR", MYSQL_SET_CHARSET_DIR, CONST_CS | CONST_PERSISTENT);
|
2006-01-14 22:15:41 +08:00
|
|
|
|
2005-04-20 20:50:13 +08:00
|
|
|
/* bind support */
|
2014-08-26 01:24:55 +08:00
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_NO_DATA", MYSQL_NO_DATA, CONST_CS | CONST_PERSISTENT);
|
2005-04-20 21:03:01 +08:00
|
|
|
#ifdef MYSQL_DATA_TRUNCATED
|
2014-08-26 01:24:55 +08:00
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_DATA_TRUNCATED", MYSQL_DATA_TRUNCATED, CONST_CS | CONST_PERSISTENT);
|
2005-04-20 20:50:13 +08:00
|
|
|
#endif
|
2003-03-11 09:19:21 +08:00
|
|
|
|
2003-12-13 08:28:21 +08:00
|
|
|
/* reporting */
|
2014-08-26 01:24:55 +08:00
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_REPORT_INDEX", MYSQLI_REPORT_INDEX, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_REPORT_ERROR", MYSQLI_REPORT_ERROR, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_REPORT_STRICT", MYSQLI_REPORT_STRICT, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_REPORT_ALL", MYSQLI_REPORT_ALL, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_REPORT_OFF", 0, CONST_CS | CONST_PERSISTENT);
|
2003-03-11 09:19:21 +08:00
|
|
|
|
2008-02-13 06:05:34 +08:00
|
|
|
/* We use non-nested macros with expansion, as VC has problems */
|
2008-03-11 04:15:38 +08:00
|
|
|
#ifdef MYSQLI_USE_MYSQLND
|
2014-08-26 01:24:55 +08:00
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_DEBUG_TRACE_ENABLED", MYSQLND_DBG_ENABLED, CONST_CS | CONST_PERSISTENT);
|
2008-02-12 00:44:48 +08:00
|
|
|
#else
|
2011-09-06 13:20:05 +08:00
|
|
|
#ifdef DBUG_ON
|
2014-08-26 01:24:55 +08:00
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_DEBUG_TRACE_ENABLED", 1, CONST_CS | CONST_PERSISTENT);
|
2011-09-06 13:20:05 +08:00
|
|
|
#else
|
2014-08-26 01:24:55 +08:00
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_DEBUG_TRACE_ENABLED", 0, CONST_CS | CONST_PERSISTENT);
|
2008-02-12 00:44:48 +08:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2014-08-26 01:24:55 +08:00
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_SERVER_QUERY_NO_GOOD_INDEX_USED", SERVER_QUERY_NO_GOOD_INDEX_USED, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_SERVER_QUERY_NO_INDEX_USED", SERVER_QUERY_NO_INDEX_USED, CONST_CS | CONST_PERSISTENT);
|
2008-07-15 21:11:09 +08:00
|
|
|
#ifdef SERVER_QUERY_WAS_SLOW
|
2014-08-26 01:24:55 +08:00
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_SERVER_QUERY_WAS_SLOW", SERVER_QUERY_WAS_SLOW, CONST_CS | CONST_PERSISTENT);
|
2008-07-15 21:11:09 +08:00
|
|
|
#endif
|
2010-12-02 22:21:23 +08:00
|
|
|
#ifdef SERVER_PS_OUT_PARAMS
|
2014-08-26 01:24:55 +08:00
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_SERVER_PS_OUT_PARAMS", SERVER_PS_OUT_PARAMS, CONST_CS | CONST_PERSISTENT);
|
2010-12-02 22:21:23 +08:00
|
|
|
#endif
|
2008-07-15 21:11:09 +08:00
|
|
|
|
2014-08-26 01:24:55 +08:00
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_GRANT", REFRESH_GRANT, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_LOG", REFRESH_LOG, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_TABLES", REFRESH_TABLES, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_HOSTS", REFRESH_HOSTS, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_STATUS", REFRESH_STATUS, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_THREADS", REFRESH_THREADS, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_SLAVE", REFRESH_SLAVE, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_MASTER", REFRESH_MASTER, CONST_CS | CONST_PERSISTENT);
|
2009-01-23 05:01:58 +08:00
|
|
|
#ifdef REFRESH_BACKUP_LOG
|
2014-08-26 01:24:55 +08:00
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_BACKUP_LOG", REFRESH_BACKUP_LOG, CONST_CS | CONST_PERSISTENT);
|
2009-01-23 05:01:58 +08:00
|
|
|
#endif
|
|
|
|
|
2011-09-01 04:30:08 +08:00
|
|
|
|
2014-08-26 01:24:55 +08:00
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT", TRANS_START_WITH_CONSISTENT_SNAPSHOT, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TRANS_START_READ_WRITE", TRANS_START_READ_WRITE, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TRANS_START_READ_ONLY", TRANS_START_READ_ONLY, CONST_CS | CONST_PERSISTENT);
|
2013-02-09 00:05:25 +08:00
|
|
|
|
2014-08-26 01:24:55 +08:00
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TRANS_COR_AND_CHAIN", TRANS_COR_AND_CHAIN, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TRANS_COR_AND_NO_CHAIN", TRANS_COR_AND_NO_CHAIN, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TRANS_COR_RELEASE", TRANS_COR_RELEASE, CONST_CS | CONST_PERSISTENT);
|
|
|
|
REGISTER_LONG_CONSTANT("MYSQLI_TRANS_COR_NO_RELEASE", TRANS_COR_NO_RELEASE, CONST_CS | CONST_PERSISTENT);
|
2013-02-09 00:05:25 +08:00
|
|
|
|
|
|
|
|
2011-09-05 21:05:15 +08:00
|
|
|
#ifdef MYSQLI_USE_MYSQLND
|
2014-12-14 06:06:14 +08:00
|
|
|
mysqlnd_reverse_api_register_api(&mysqli_reverse_api);
|
2011-09-01 04:30:08 +08:00
|
|
|
#endif
|
|
|
|
|
2003-02-12 08:45:53 +08:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ PHP_MSHUTDOWN_FUNCTION
|
|
|
|
*/
|
|
|
|
PHP_MSHUTDOWN_FUNCTION(mysqli)
|
|
|
|
{
|
2008-03-11 04:15:38 +08:00
|
|
|
#ifndef MYSQLI_USE_MYSQLND
|
2007-10-06 05:23:56 +08:00
|
|
|
#if MYSQL_VERSION_ID >= 40000
|
2007-06-26 00:01:30 +08:00
|
|
|
#ifdef PHP_WIN32
|
2014-08-26 01:24:55 +08:00
|
|
|
zend_ulong client_ver = mysql_get_client_version();
|
2007-10-06 05:23:56 +08:00
|
|
|
/*
|
2008-03-08 23:00:50 +08:00
|
|
|
Can't call mysql_server_end() multiple times prior to 5.0.46 on Windows.
|
2007-10-06 05:23:56 +08:00
|
|
|
PHP bug#41350 MySQL bug#25621
|
|
|
|
*/
|
2008-03-08 23:00:50 +08:00
|
|
|
if ((client_ver >= 50046 && client_ver < 50100) || client_ver > 50122) {
|
2007-06-26 00:01:30 +08:00
|
|
|
mysql_server_end();
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
mysql_server_end();
|
|
|
|
#endif
|
2007-10-06 05:23:56 +08:00
|
|
|
#endif
|
|
|
|
#endif
|
2007-06-26 00:01:30 +08:00
|
|
|
|
2005-01-08 00:34:55 +08:00
|
|
|
zend_hash_destroy(&mysqli_driver_properties);
|
2003-12-10 18:06:07 +08:00
|
|
|
zend_hash_destroy(&mysqli_result_properties);
|
|
|
|
zend_hash_destroy(&mysqli_stmt_properties);
|
2005-01-07 22:59:59 +08:00
|
|
|
zend_hash_destroy(&mysqli_warning_properties);
|
|
|
|
zend_hash_destroy(&mysqli_link_properties);
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
zend_hash_destroy(&classes);
|
|
|
|
|
2003-02-12 08:45:53 +08:00
|
|
|
UNREGISTER_INI_ENTRIES();
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ PHP_RINIT_FUNCTION
|
|
|
|
*/
|
|
|
|
PHP_RINIT_FUNCTION(mysqli)
|
|
|
|
{
|
2008-03-11 04:15:38 +08:00
|
|
|
#if !defined(MYSQLI_USE_MYSQLND) && defined(ZTS) && MYSQL_VERSION_ID >= 40000
|
2007-06-26 00:01:30 +08:00
|
|
|
if (mysql_thread_init()) {
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
#endif
|
2003-02-15 00:49:09 +08:00
|
|
|
MyG(error_msg) = NULL;
|
|
|
|
MyG(error_no) = 0;
|
2010-08-13 18:43:15 +08:00
|
|
|
MyG(report_mode) = 0;
|
2003-02-15 00:49:09 +08:00
|
|
|
|
2003-02-12 08:45:53 +08:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2011-08-02 22:02:21 +08:00
|
|
|
#if defined(A0) && defined(MYSQLI_USE_MYSQLND)
|
2008-06-25 06:22:48 +08:00
|
|
|
static void php_mysqli_persistent_helper_for_every(void *p)
|
|
|
|
{
|
|
|
|
mysqlnd_end_psession((MYSQLND *) p);
|
|
|
|
} /* }}} */
|
|
|
|
|
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
static int php_mysqli_persistent_helper_once(zend_rsrc_list_entry *le)
|
2008-06-25 06:22:48 +08:00
|
|
|
{
|
|
|
|
if (le->type == php_le_pmysqli()) {
|
|
|
|
mysqli_plist_entry *plist = (mysqli_plist_entry *) le->ptr;
|
|
|
|
zend_ptr_stack_apply(&plist->free_links, php_mysqli_persistent_helper_for_every);
|
|
|
|
}
|
|
|
|
return ZEND_HASH_APPLY_KEEP;
|
|
|
|
} /* }}} */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2003-02-12 08:45:53 +08:00
|
|
|
/* {{{ PHP_RSHUTDOWN_FUNCTION
|
|
|
|
*/
|
|
|
|
PHP_RSHUTDOWN_FUNCTION(mysqli)
|
|
|
|
{
|
2007-10-06 05:23:56 +08:00
|
|
|
/* check persistent connections, move used to free */
|
|
|
|
|
2008-03-11 04:15:38 +08:00
|
|
|
#if !defined(MYSQLI_USE_MYSQLND) && defined(ZTS) && MYSQL_VERSION_ID >= 40000
|
2007-06-26 00:01:30 +08:00
|
|
|
mysql_thread_end();
|
|
|
|
#endif
|
2003-02-15 00:49:09 +08:00
|
|
|
if (MyG(error_msg)) {
|
|
|
|
efree(MyG(error_msg));
|
|
|
|
}
|
2011-08-02 22:02:21 +08:00
|
|
|
#if defined(A0) && defined(MYSQLI_USE_MYSQLND)
|
2010-10-01 02:10:03 +08:00
|
|
|
/* psession is being called when the connection is freed - explicitly or implicitly */
|
2014-12-14 06:06:14 +08:00
|
|
|
zend_hash_apply(&EG(persistent_list), (apply_func_t) php_mysqli_persistent_helper_once);
|
2007-10-06 05:23:56 +08:00
|
|
|
#endif
|
2003-02-12 08:45:53 +08:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2007-10-06 05:23:56 +08:00
|
|
|
|
2003-02-12 08:45:53 +08:00
|
|
|
/* {{{ PHP_MINFO_FUNCTION
|
|
|
|
*/
|
|
|
|
PHP_MINFO_FUNCTION(mysqli)
|
|
|
|
{
|
2007-10-06 05:23:56 +08:00
|
|
|
char buf[32];
|
|
|
|
|
2003-02-12 08:45:53 +08:00
|
|
|
php_info_print_table_start();
|
|
|
|
php_info_print_table_header(2, "MysqlI Support", "enabled");
|
2006-04-02 17:40:19 +08:00
|
|
|
php_info_print_table_row(2, "Client API library version", mysql_get_client_info());
|
2014-08-26 02:22:49 +08:00
|
|
|
snprintf(buf, sizeof(buf), ZEND_LONG_FMT, MyG(num_active_persistent));
|
2007-10-06 05:23:56 +08:00
|
|
|
php_info_print_table_row(2, "Active Persistent Links", buf);
|
2014-08-26 02:22:49 +08:00
|
|
|
snprintf(buf, sizeof(buf), ZEND_LONG_FMT, MyG(num_inactive_persistent));
|
2007-10-06 05:23:56 +08:00
|
|
|
php_info_print_table_row(2, "Inactive Persistent Links", buf);
|
2014-08-26 02:22:49 +08:00
|
|
|
snprintf(buf, sizeof(buf), ZEND_LONG_FMT, MyG(num_links));
|
2007-10-06 05:23:56 +08:00
|
|
|
php_info_print_table_row(2, "Active Links", buf);
|
2008-03-11 04:15:38 +08:00
|
|
|
#if !defined(MYSQLI_USE_MYSQLND)
|
2006-04-02 17:40:19 +08:00
|
|
|
php_info_print_table_row(2, "Client API header version", MYSQL_SERVER_VERSION);
|
2003-02-12 08:45:53 +08:00
|
|
|
php_info_print_table_row(2, "MYSQLI_SOCKET", MYSQL_UNIX_ADDR);
|
2007-10-06 05:23:56 +08:00
|
|
|
#endif
|
2003-02-12 08:45:53 +08:00
|
|
|
php_info_print_table_end();
|
|
|
|
|
|
|
|
DISPLAY_INI_ENTRIES();
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2010-08-20 20:25:17 +08:00
|
|
|
|
|
|
|
/* Dependancies */
|
|
|
|
static const zend_module_dep mysqli_deps[] = {
|
2014-08-15 18:28:41 +08:00
|
|
|
#if defined(HAVE_SPL) && (PHP_VERSION_ID >= 50100)
|
2010-08-20 20:25:17 +08:00
|
|
|
ZEND_MOD_REQUIRED("spl")
|
|
|
|
#endif
|
|
|
|
#if defined(MYSQLI_USE_MYSQLND)
|
|
|
|
ZEND_MOD_REQUIRED("mysqlnd")
|
|
|
|
#endif
|
2011-08-06 22:47:44 +08:00
|
|
|
ZEND_MOD_END
|
2010-08-20 20:25:17 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* {{{ mysqli_module_entry
|
|
|
|
*/
|
|
|
|
zend_module_entry mysqli_module_entry = {
|
|
|
|
STANDARD_MODULE_HEADER_EX, NULL,
|
|
|
|
mysqli_deps,
|
|
|
|
"mysqli",
|
|
|
|
mysqli_functions,
|
|
|
|
PHP_MINIT(mysqli),
|
|
|
|
PHP_MSHUTDOWN(mysqli),
|
|
|
|
PHP_RINIT(mysqli),
|
|
|
|
PHP_RSHUTDOWN(mysqli),
|
|
|
|
PHP_MINFO(mysqli),
|
2015-03-24 03:33:54 +08:00
|
|
|
PHP_MYSQLI_VERSION,
|
2010-08-20 20:25:17 +08:00
|
|
|
PHP_MODULE_GLOBALS(mysqli),
|
|
|
|
PHP_GINIT(mysqli),
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
STANDARD_MODULE_PROPERTIES_EX
|
|
|
|
};
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
#ifdef COMPILE_DL_MYSQLI
|
2014-10-15 18:08:25 +08:00
|
|
|
#ifdef ZTS
|
2015-02-17 00:19:32 +08:00
|
|
|
ZEND_TSRMLS_CACHE_DEFINE();
|
2014-10-15 18:08:25 +08:00
|
|
|
#endif
|
2010-08-20 20:25:17 +08:00
|
|
|
ZEND_GET_MODULE(mysqli)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2010-10-04 18:02:58 +08:00
|
|
|
/* {{{ mixed mysqli_stmt_construct()
|
2004-12-26 21:16:40 +08:00
|
|
|
constructor for statement object.
|
2010-10-04 18:02:58 +08:00
|
|
|
Parameters:
|
2006-03-24 17:32:24 +08:00
|
|
|
object -> mysqli_stmt_init
|
2004-12-26 21:16:40 +08:00
|
|
|
object, query -> mysqli_prepare
|
|
|
|
*/
|
2008-03-19 00:57:31 +08:00
|
|
|
PHP_FUNCTION(mysqli_stmt_construct)
|
2004-12-26 21:16:40 +08:00
|
|
|
{
|
|
|
|
MY_MYSQL *mysql;
|
2007-10-06 05:23:56 +08:00
|
|
|
zval *mysql_link;
|
2004-12-26 21:16:40 +08:00
|
|
|
MY_STMT *stmt;
|
2007-10-06 05:23:56 +08:00
|
|
|
MYSQLI_RESOURCE *mysqli_resource;
|
2005-10-11 04:03:00 +08:00
|
|
|
char *statement;
|
2014-08-27 21:31:48 +08:00
|
|
|
size_t statement_len;
|
2004-12-26 21:16:40 +08:00
|
|
|
|
|
|
|
switch (ZEND_NUM_ARGS())
|
|
|
|
{
|
|
|
|
case 1: /* mysql_stmt_init */
|
2014-12-14 06:06:14 +08:00
|
|
|
if (zend_parse_parameters(1, "O", &mysql_link, mysqli_link_class_entry)==FAILURE) {
|
2004-12-26 21:16:40 +08:00
|
|
|
return;
|
|
|
|
}
|
2014-05-11 14:53:18 +08:00
|
|
|
MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID);
|
2004-12-26 21:16:40 +08:00
|
|
|
|
|
|
|
stmt = (MY_STMT *)ecalloc(1,sizeof(MY_STMT));
|
|
|
|
|
|
|
|
stmt->stmt = mysql_stmt_init(mysql->mysql);
|
|
|
|
break;
|
|
|
|
case 2:
|
2014-12-14 06:06:14 +08:00
|
|
|
if (zend_parse_parameters(2, "Os", &mysql_link, mysqli_link_class_entry, &statement, &statement_len)==FAILURE) {
|
2004-12-26 21:16:40 +08:00
|
|
|
return;
|
|
|
|
}
|
2014-05-11 14:53:18 +08:00
|
|
|
MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID);
|
2004-12-26 21:16:40 +08:00
|
|
|
|
|
|
|
stmt = (MY_STMT *)ecalloc(1,sizeof(MY_STMT));
|
2007-10-06 05:23:56 +08:00
|
|
|
|
2004-12-26 21:16:40 +08:00
|
|
|
if ((stmt->stmt = mysql_stmt_init(mysql->mysql))) {
|
2008-03-19 00:57:31 +08:00
|
|
|
mysql_stmt_prepare(stmt->stmt, (char *)statement, statement_len);
|
2004-12-26 21:16:40 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WRONG_PARAM_COUNT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!stmt->stmt) {
|
|
|
|
efree(stmt);
|
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
2014-02-27 15:45:16 +08:00
|
|
|
#ifndef MYSQLI_USE_MYSQLND
|
2014-05-11 14:53:18 +08:00
|
|
|
ZVAL_COPY(&stmt->link_handle, mysql_link);
|
2014-02-27 15:45:16 +08:00
|
|
|
#endif
|
2004-12-26 21:16:40 +08:00
|
|
|
|
|
|
|
mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
|
|
|
|
mysqli_resource->ptr = (void *)stmt;
|
2006-03-24 17:32:24 +08:00
|
|
|
mysqli_resource->status = (ZEND_NUM_ARGS() == 1) ? MYSQLI_STATUS_INITIALIZED : MYSQLI_STATUS_VALID;
|
|
|
|
|
2014-05-11 14:53:18 +08:00
|
|
|
MYSQLI_REGISTER_RESOURCE_EX(mysqli_resource, getThis());
|
2004-12-26 21:16:40 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2010-10-04 18:02:58 +08:00
|
|
|
/* {{{ mixed mysqli_result_construct()
|
2004-12-26 21:16:40 +08:00
|
|
|
constructor for result object.
|
2010-10-04 18:02:58 +08:00
|
|
|
Parameters:
|
2004-12-26 21:16:40 +08:00
|
|
|
object [, mode] -> mysqli_store/use_result
|
|
|
|
*/
|
2008-03-19 00:57:31 +08:00
|
|
|
PHP_FUNCTION(mysqli_result_construct)
|
2004-12-26 21:16:40 +08:00
|
|
|
{
|
|
|
|
MY_MYSQL *mysql;
|
2008-01-29 02:25:50 +08:00
|
|
|
MYSQL_RES *result = NULL;
|
2005-10-11 04:03:00 +08:00
|
|
|
zval *mysql_link;
|
2007-10-06 05:23:56 +08:00
|
|
|
MYSQLI_RESOURCE *mysqli_resource;
|
2014-08-26 01:24:55 +08:00
|
|
|
zend_long resmode = MYSQLI_STORE_RESULT;
|
2004-12-26 21:16:40 +08:00
|
|
|
|
|
|
|
switch (ZEND_NUM_ARGS()) {
|
|
|
|
case 1:
|
2014-12-14 06:06:14 +08:00
|
|
|
if (zend_parse_parameters(1, "O", &mysql_link, mysqli_link_class_entry)==FAILURE) {
|
2004-12-26 21:16:40 +08:00
|
|
|
return;
|
|
|
|
}
|
2007-10-06 05:23:56 +08:00
|
|
|
break;
|
2004-12-26 21:16:40 +08:00
|
|
|
case 2:
|
2014-12-14 06:06:14 +08:00
|
|
|
if (zend_parse_parameters(2, "Ol", &mysql_link, mysqli_link_class_entry, &resmode)==FAILURE) {
|
2004-12-26 21:16:40 +08:00
|
|
|
return;
|
|
|
|
}
|
2007-10-06 05:23:56 +08:00
|
|
|
break;
|
2004-12-26 21:16:40 +08:00
|
|
|
default:
|
|
|
|
WRONG_PARAM_COUNT;
|
|
|
|
}
|
|
|
|
|
2014-05-11 14:53:18 +08:00
|
|
|
MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID);
|
2004-12-26 21:16:40 +08:00
|
|
|
|
2008-01-29 02:25:50 +08:00
|
|
|
switch (resmode) {
|
|
|
|
case MYSQLI_STORE_RESULT:
|
|
|
|
result = mysql_store_result(mysql->mysql);
|
|
|
|
break;
|
|
|
|
case MYSQLI_USE_RESULT:
|
|
|
|
result = mysql_use_result(mysql->mysql);
|
|
|
|
break;
|
|
|
|
default:
|
2014-12-14 06:06:14 +08:00
|
|
|
php_error_docref(NULL, E_WARNING, "Invalid value for resultmode");
|
2008-01-29 02:25:50 +08:00
|
|
|
}
|
2004-12-26 21:16:40 +08:00
|
|
|
|
|
|
|
if (!result) {
|
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
|
|
|
|
mysqli_resource->ptr = (void *)result;
|
2006-03-24 17:32:24 +08:00
|
|
|
mysqli_resource->status = MYSQLI_STATUS_VALID;
|
2007-10-06 05:23:56 +08:00
|
|
|
|
2014-05-11 14:53:18 +08:00
|
|
|
MYSQLI_REGISTER_RESOURCE_EX(mysqli_resource, getThis());
|
2004-12-26 21:16:40 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
2010-05-18 18:39:26 +08:00
|
|
|
/* {{{ php_mysqli_fetch_into_hash_aux
|
2003-02-12 08:45:53 +08:00
|
|
|
*/
|
2014-12-14 06:06:14 +08:00
|
|
|
void php_mysqli_fetch_into_hash_aux(zval *return_value, MYSQL_RES * result, zend_long fetchtype)
|
2003-02-12 08:45:53 +08:00
|
|
|
{
|
2010-10-05 17:40:36 +08:00
|
|
|
#if !defined(MYSQLI_USE_MYSQLND)
|
2010-05-18 18:39:26 +08:00
|
|
|
MYSQL_ROW row;
|
2003-03-09 07:33:12 +08:00
|
|
|
unsigned int i;
|
|
|
|
MYSQL_FIELD *fields;
|
2014-08-26 01:24:55 +08:00
|
|
|
zend_ulong *field_len;
|
2015-01-03 17:22:58 +08:00
|
|
|
|
2003-02-22 15:31:01 +08:00
|
|
|
if (!(row = mysql_fetch_row(result))) {
|
- Added multiquery support:
mysqli_multi_query
mysqli_more_results
mysqli_next_results
- added read-only properties (and removed methods)
object mysql
affected_rows
client_flags
client_version
errno, error,
host, host_info, info
server_capabilities, server_version
sqlstate, port, protocol_version,
server_language
thread_id, user, warning_count
object result
current_field, field_count,
lengths, num_rows, type
object stmt
query, param_count, field_count,
id, errno, error, sqlstate
- added constructor
- minor fixes, prototypes
2003-11-23 05:20:07 +08:00
|
|
|
RETURN_NULL();
|
2003-02-22 15:31:01 +08:00
|
|
|
}
|
2003-03-09 07:33:12 +08:00
|
|
|
|
2003-12-13 08:28:21 +08:00
|
|
|
if (fetchtype & MYSQLI_ASSOC) {
|
|
|
|
fields = mysql_fetch_fields(result);
|
|
|
|
}
|
|
|
|
|
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]) {
|
2014-05-11 14:53:18 +08:00
|
|
|
zval res;
|
2003-11-08 01:20:49 +08:00
|
|
|
|
2009-09-22 23:08:11 +08:00
|
|
|
#if MYSQL_VERSION_ID > 50002
|
|
|
|
if (mysql_fetch_field_direct(result, i)->type == MYSQL_TYPE_BIT) {
|
|
|
|
my_ulonglong llval;
|
|
|
|
char tmp[22];
|
|
|
|
switch (field_len[i]) {
|
|
|
|
case 8:llval = (my_ulonglong) bit_uint8korr(row[i]);break;
|
|
|
|
case 7:llval = (my_ulonglong) bit_uint7korr(row[i]);break;
|
|
|
|
case 6:llval = (my_ulonglong) bit_uint6korr(row[i]);break;
|
|
|
|
case 5:llval = (my_ulonglong) bit_uint5korr(row[i]);break;
|
|
|
|
case 4:llval = (my_ulonglong) bit_uint4korr(row[i]);break;
|
|
|
|
case 3:llval = (my_ulonglong) bit_uint3korr(row[i]);break;
|
|
|
|
case 2:llval = (my_ulonglong) bit_uint2korr(row[i]);break;
|
|
|
|
case 1:llval = (my_ulonglong) uint1korr(row[i]);break;
|
|
|
|
}
|
|
|
|
/* even though lval is declared as unsigned, the value
|
|
|
|
* may be negative. Therefor we cannot use MYSQLI_LLU_SPEC and must
|
|
|
|
* use MYSQLI_LL_SPEC.
|
|
|
|
*/
|
|
|
|
snprintf(tmp, sizeof(tmp), (mysql_fetch_field_direct(result, i)->flags & UNSIGNED_FLAG)? MYSQLI_LLU_SPEC : MYSQLI_LL_SPEC, llval);
|
2014-05-11 14:53:18 +08:00
|
|
|
ZVAL_STRING(&res, tmp);
|
2010-10-04 18:02:58 +08:00
|
|
|
} else
|
2009-09-22 23:08:11 +08:00
|
|
|
#endif
|
|
|
|
{
|
|
|
|
|
2015-01-20 10:11:48 +08:00
|
|
|
ZVAL_STRINGL(&res, row[i], field_len[i]);
|
2003-02-12 08:45:53 +08:00
|
|
|
}
|
2003-11-08 01:20:49 +08:00
|
|
|
|
2003-02-12 08:45:53 +08:00
|
|
|
if (fetchtype & MYSQLI_NUM) {
|
2014-05-11 14:53:18 +08:00
|
|
|
add_index_zval(return_value, i, &res);
|
2003-02-12 08:45:53 +08:00
|
|
|
}
|
|
|
|
if (fetchtype & MYSQLI_ASSOC) {
|
2014-05-11 14:53:18 +08:00
|
|
|
if (fetchtype & MYSQLI_NUM && Z_REFCOUNTED(res)) {
|
|
|
|
Z_ADDREF(res);
|
2003-11-08 01:20:49 +08:00
|
|
|
}
|
2014-05-11 14:53:18 +08:00
|
|
|
add_assoc_zval(return_value, fields[i].name, &res);
|
2003-02-12 08:45:53 +08:00
|
|
|
}
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-10-06 05:23:56 +08:00
|
|
|
#else
|
2010-05-18 18:39:26 +08:00
|
|
|
mysqlnd_fetch_into(result, ((fetchtype & MYSQLI_NUM)? MYSQLND_FETCH_NUM:0) | ((fetchtype & MYSQLI_ASSOC)? MYSQLND_FETCH_ASSOC:0), return_value, MYSQLND_MYSQLI);
|
2007-10-06 05:23:56 +08:00
|
|
|
#endif
|
2010-05-18 18:39:26 +08:00
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ php_mysqli_fetch_into_hash
|
|
|
|
*/
|
|
|
|
void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags, int into_object)
|
|
|
|
{
|
|
|
|
MYSQL_RES *result;
|
|
|
|
zval *mysql_result;
|
2014-08-26 01:24:55 +08:00
|
|
|
zend_long fetchtype;
|
2010-05-18 18:39:26 +08:00
|
|
|
zval *ctor_params = NULL;
|
|
|
|
zend_class_entry *ce = NULL;
|
|
|
|
|
|
|
|
if (into_object) {
|
2014-05-11 14:53:18 +08:00
|
|
|
zend_string *class_name = NULL;
|
2010-05-18 18:39:26 +08:00
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|Sz", &mysql_result, mysqli_result_class_entry, &class_name, &ctor_params) == FAILURE) {
|
2010-05-18 18:39:26 +08:00
|
|
|
return;
|
|
|
|
}
|
2014-05-11 16:05:14 +08:00
|
|
|
if (class_name == NULL) {
|
2010-05-18 18:39:26 +08:00
|
|
|
ce = zend_standard_class_def;
|
|
|
|
} else {
|
2014-12-14 06:06:14 +08:00
|
|
|
ce = zend_fetch_class(class_name, ZEND_FETCH_CLASS_AUTO);
|
2010-05-18 18:39:26 +08:00
|
|
|
}
|
|
|
|
if (!ce) {
|
2015-06-30 09:05:24 +08:00
|
|
|
php_error_docref(NULL, E_WARNING, "Could not find class '%s'", ZSTR_VAL(class_name));
|
2010-05-18 18:39:26 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
fetchtype = MYSQLI_ASSOC;
|
|
|
|
} else {
|
|
|
|
if (override_flags) {
|
2014-12-14 06:06:14 +08:00
|
|
|
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &mysql_result, mysqli_result_class_entry) == FAILURE) {
|
2010-05-18 18:39:26 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
fetchtype = override_flags;
|
|
|
|
} else {
|
|
|
|
fetchtype = MYSQLI_BOTH;
|
2014-12-14 06:06:14 +08:00
|
|
|
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|l", &mysql_result, mysqli_result_class_entry, &fetchtype) == FAILURE) {
|
2010-05-18 18:39:26 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-05-11 14:53:18 +08:00
|
|
|
MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
|
2010-05-18 18:39:26 +08:00
|
|
|
|
|
|
|
if (fetchtype < MYSQLI_ASSOC || fetchtype > MYSQLI_BOTH) {
|
2014-12-14 06:06:14 +08:00
|
|
|
php_error_docref(NULL, E_WARNING, "The result type should be either MYSQLI_NUM, MYSQLI_ASSOC or MYSQLI_BOTH");
|
2010-05-18 18:39:26 +08:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
php_mysqli_fetch_into_hash_aux(return_value, result, fetchtype);
|
2003-03-09 07:33:12 +08:00
|
|
|
|
2013-04-27 23:41:31 +08:00
|
|
|
if (into_object && Z_TYPE_P(return_value) == IS_ARRAY) {
|
2014-05-11 14:53:18 +08:00
|
|
|
zval dataset, retval;
|
2003-09-07 03:34:48 +08:00
|
|
|
zend_fcall_info fci;
|
|
|
|
zend_fcall_info_cache fcc;
|
2014-05-11 14:53:18 +08:00
|
|
|
|
|
|
|
ZVAL_COPY_VALUE(&dataset, return_value);
|
2007-10-06 05:23:56 +08:00
|
|
|
|
2003-09-07 03:34:48 +08:00
|
|
|
object_and_properties_init(return_value, ce, NULL);
|
2014-06-04 06:11:26 +08:00
|
|
|
if (!ce->default_properties_count && !ce->__set) {
|
2015-09-15 04:04:27 +08:00
|
|
|
Z_OBJ_P(return_value)->properties = Z_ARR(dataset);
|
2014-06-04 06:11:26 +08:00
|
|
|
} else {
|
2014-12-14 06:06:14 +08:00
|
|
|
zend_merge_properties(return_value, Z_ARRVAL(dataset));
|
2014-06-04 06:11:26 +08:00
|
|
|
zval_ptr_dtor(&dataset);
|
|
|
|
}
|
2007-10-06 05:23:56 +08:00
|
|
|
|
2003-09-07 03:34:48 +08:00
|
|
|
if (ce->constructor) {
|
|
|
|
fci.size = sizeof(fci);
|
|
|
|
fci.function_table = &ce->function_table;
|
2014-05-11 14:53:18 +08:00
|
|
|
ZVAL_UNDEF(&fci.function_name);
|
2003-09-07 03:34:48 +08:00
|
|
|
fci.symbol_table = NULL;
|
2014-05-11 14:53:18 +08:00
|
|
|
fci.object = Z_OBJ_P(return_value);
|
|
|
|
fci.retval = &retval;
|
2014-04-08 02:46:45 +08:00
|
|
|
fci.params = NULL;
|
|
|
|
fci.param_count = 0;
|
|
|
|
fci.no_separation = 1;
|
|
|
|
|
2003-09-07 03:34:48 +08:00
|
|
|
if (ctor_params && Z_TYPE_P(ctor_params) != IS_NULL) {
|
2014-12-14 06:06:14 +08:00
|
|
|
if (zend_fcall_info_args(&fci, ctor_params) == FAILURE) {
|
2003-09-07 03:34:48 +08:00
|
|
|
/* Two problems why we throw exceptions here: PHP is typeless
|
|
|
|
* and hence passing one argument that's not an array could be
|
2010-10-04 18:02:58 +08:00
|
|
|
* by mistake and the other way round is possible, too. The
|
2003-09-07 03:34:48 +08:00
|
|
|
* single value is an array. Also we'd have to make that one
|
|
|
|
* argument passed by reference.
|
|
|
|
*/
|
2015-07-03 22:45:03 +08:00
|
|
|
zend_throw_exception(zend_ce_exception, "Parameter ctor_params must be an array", 0);
|
2003-09-07 03:34:48 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fcc.initialized = 1;
|
|
|
|
fcc.function_handler = ce->constructor;
|
|
|
|
fcc.calling_scope = EG(scope);
|
2008-07-25 16:23:07 +08:00
|
|
|
fcc.called_scope = Z_OBJCE_P(return_value);
|
2014-05-11 14:53:18 +08:00
|
|
|
fcc.object = Z_OBJ_P(return_value);
|
2007-10-06 05:23:56 +08:00
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
if (zend_call_function(&fci, &fcc) == FAILURE) {
|
2015-07-03 22:45:03 +08:00
|
|
|
zend_throw_exception_ex(zend_ce_exception, 0, "Could not execute %s::%s()", ZSTR_VAL(ce->name), ZSTR_VAL(ce->constructor->common.function_name));
|
2003-09-07 03:34:48 +08:00
|
|
|
} else {
|
2014-05-11 14:53:18 +08:00
|
|
|
zval_ptr_dtor(&retval);
|
2003-09-07 03:34:48 +08:00
|
|
|
}
|
|
|
|
if (fci.params) {
|
|
|
|
efree(fci.params);
|
|
|
|
}
|
|
|
|
} else if (ctor_params) {
|
2015-07-03 22:45:03 +08:00
|
|
|
zend_throw_exception_ex(zend_ce_exception, 0, "Class %s does not have a constructor hence you cannot use ctor_params", ZSTR_VAL(ce->name));
|
2003-09-07 03:34:48 +08:00
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
*/
|