Back to index

php5  5.3.10
mysqli_driver.c
Go to the documentation of this file.
00001 /*
00002   +----------------------------------------------------------------------+
00003   | PHP Version 5                                                        |
00004   +----------------------------------------------------------------------+
00005   | Copyright (c) 1997-2012 The PHP Group                                |
00006   +----------------------------------------------------------------------+
00007   | This source file is subject to version 3.01 of the PHP license,      |
00008   | that is bundled with this package in the file LICENSE, and is        |
00009   | available through the world-wide-web at the following url:           |
00010   | http://www.php.net/license/3_01.txt                                  |
00011   | If you did not receive a copy of the PHP license and are unable to   |
00012   | obtain it through the world-wide-web, please send a note to          |
00013   | license@php.net so we can mail you a copy immediately.               |
00014   +----------------------------------------------------------------------+
00015   | Author: Georg Richter <georg@php.net>                                |
00016   +----------------------------------------------------------------------+
00017 
00018 */
00019 #ifdef HAVE_CONFIG_H
00020 #include "config.h"
00021 #endif
00022 
00023 #include <signal.h>
00024 
00025 #include "php.h"
00026 #include "php_ini.h"
00027 #include "ext/standard/info.h"
00028 #include "php_mysqli_structs.h"
00029 #include "zend_exceptions.h"
00030 #include "mysqli_fe.h"
00031 
00032 #define MAP_PROPERTY_MYG_BOOL_READ(name, value) \
00033 static int name(mysqli_object *obj, zval **retval TSRMLS_DC) \
00034 { \
00035        MAKE_STD_ZVAL(*retval); \
00036        ZVAL_BOOL(*retval, MyG(value)); \
00037        return SUCCESS; \
00038 } \
00039 
00040 #define MAP_PROPERTY_MYG_BOOL_WRITE(name, value) \
00041 static int name(mysqli_object *obj, zval *value TSRMLS_DC) \
00042 { \
00043        MyG(value) = Z_LVAL_P(value) > 0; \
00044        return SUCCESS; \
00045 } \
00046 
00047 #define MAP_PROPERTY_MYG_LONG_READ(name, value) \
00048 static int name(mysqli_object *obj, zval **retval TSRMLS_DC) \
00049 { \
00050        MAKE_STD_ZVAL(*retval); \
00051        ZVAL_LONG(*retval, MyG(value)); \
00052        return SUCCESS; \
00053 } \
00054 
00055 #define MAP_PROPERTY_MYG_LONG_WRITE(name, value) \
00056 static int name(mysqli_object *obj, zval *value TSRMLS_DC) \
00057 { \
00058        MyG(value) = Z_LVAL_P(value); \
00059        return SUCCESS; \
00060 } \
00061 
00062 #define MAP_PROPERTY_MYG_STRING_READ(name, value) \
00063 static int name(mysqli_object *obj, zval **retval TSRMLS_DC) \
00064 { \
00065        MAKE_STD_ZVAL(*retval); \
00066        ZVAL_STRING(*retval, MyG(value), 1); \
00067        return SUCCESS; \
00068 } \
00069 
00070 #define MAP_PROPERTY_MYG_STRING_WRITE(name, value) \
00071 static int name(mysqli_object *obj, zval *value TSRMLS_DC) \
00072 { \
00073        MyG(value) = Z_STRVAL_P(value); \
00074        return SUCCESS; \
00075 } \
00076 
00077 /* {{{ property driver_report_write */
00078 static int driver_report_write(mysqli_object *obj, zval *value TSRMLS_DC)
00079 {
00080        MyG(report_mode) = Z_LVAL_P(value);
00081        /*FIXME*/
00082        /* zend_replace_error_handling(MyG(report_mode) & MYSQLI_REPORT_STRICT ? EH_THROW : EH_NORMAL, NULL, NULL TSRMLS_CC); */
00083        return SUCCESS;
00084 }
00085 /* }}} */
00086 
00087 /* {{{ property driver_embedded_read */
00088 static int driver_embedded_read(mysqli_object *obj, zval **retval TSRMLS_DC)
00089 {
00090        MAKE_STD_ZVAL(*retval);
00091 #ifdef HAVE_EMBEDDED_MYSQLI
00092        ZVAL_BOOL(*retval, 1);
00093 #else
00094        ZVAL_BOOL(*retval, 0);
00095 #endif
00096        return SUCCESS;
00097 }
00098 /* }}} */
00099 
00100 /* {{{ property driver_client_version_read */
00101 static int driver_client_version_read(mysqli_object *obj, zval **retval TSRMLS_DC)
00102 {
00103        MAKE_STD_ZVAL(*retval);
00104        ZVAL_LONG(*retval, MYSQL_VERSION_ID);
00105        return SUCCESS;
00106 }
00107 /* }}} */
00108 
00109 /* {{{ property driver_client_info_read */
00110 static int driver_client_info_read(mysqli_object *obj, zval **retval TSRMLS_DC)
00111 {
00112        MAKE_STD_ZVAL(*retval);
00113        ZVAL_STRING(*retval, (char *)mysql_get_client_info(), 1);
00114        return SUCCESS;
00115 }
00116 /* }}} */
00117 
00118 /* {{{ property driver_driver_version_read */
00119 static int driver_driver_version_read(mysqli_object *obj, zval **retval TSRMLS_DC)
00120 {
00121        MAKE_STD_ZVAL(*retval);
00122        ZVAL_LONG(*retval, MYSQLI_VERSION_ID);
00123        return SUCCESS;
00124 }
00125 /* }}} */
00126 
00127 MAP_PROPERTY_MYG_BOOL_READ(driver_reconnect_read, reconnect)
00128 MAP_PROPERTY_MYG_BOOL_WRITE(driver_reconnect_write, reconnect)
00129 MAP_PROPERTY_MYG_LONG_READ(driver_report_read, report_mode)
00130 
00131 ZEND_FUNCTION(mysqli_driver_construct)
00132 {
00133 #if G0
00134        MYSQLI_RESOURCE      *mysqli_resource;
00135 
00136        mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
00137        mysqli_resource->ptr = 1;
00138        mysqli_resource->status = (ZEND_NUM_ARGS() == 1) ? MYSQLI_STATUS_INITIALIZED : MYSQLI_STATUS_VALID;
00139        ((mysqli_object *) zend_object_store_get_object(getThis() TSRMLS_CC))->ptr = mysqli_resource;
00140 #endif
00141 }
00142 
00143 const mysqli_property_entry mysqli_driver_property_entries[] = {
00144        {"client_info", sizeof("client_info") - 1, driver_client_info_read, NULL},
00145        {"client_version", sizeof("client_version") - 1, driver_client_version_read, NULL},
00146        {"driver_version", sizeof("driver_version") - 1, driver_driver_version_read, NULL},
00147        {"embedded", sizeof("embedded") - 1, driver_embedded_read, NULL},
00148        {"reconnect", sizeof("reconnect") - 1, driver_reconnect_read, driver_reconnect_write},
00149        {"report_mode", sizeof("report_mode") - 1, driver_report_read, driver_report_write},
00150        {NULL, 0, NULL, NULL}
00151 };
00152 
00153 /* {{{ mysqli_warning_property_info_entries */
00154 zend_property_info mysqli_driver_property_info_entries[] = {
00155        {ZEND_ACC_PUBLIC, "client_info",   sizeof("client_info") - 1,         0, NULL, 0, NULL},
00156        {ZEND_ACC_PUBLIC, "client_version",       sizeof("client_version") - 1,      0, NULL, 0, NULL},
00157        {ZEND_ACC_PUBLIC, "driver_version",       sizeof("driver_version") - 1,      0, NULL, 0, NULL},
00158        {ZEND_ACC_PUBLIC, "embedded",             sizeof("embedded") - 1,                   0, NULL, 0, NULL},
00159        {ZEND_ACC_PUBLIC, "reconnect",            sizeof("reconnect") - 1,           0, NULL, 0, NULL},
00160        {ZEND_ACC_PUBLIC, "report_mode",   sizeof("report_mode") - 1,         0, NULL, 0, NULL},
00161        {0,                                NULL,                0,                                                      0, NULL, 0, NULL},
00162 };
00163 /* }}} */
00164 
00165 
00166 /* {{{ mysqli_driver_methods[]
00167  */
00168 const zend_function_entry mysqli_driver_methods[] = {
00169 #if defined(HAVE_EMBEDDED_MYSQLI)
00170        PHP_FALIAS(embedded_server_start, mysqli_embedded_server_start, NULL)
00171        PHP_FALIAS(embedded_server_end, mysqli_embedded_server_end, NULL)
00172 #endif
00173        {NULL, NULL, NULL}
00174 };
00175 /* }}} */
00176 
00177 /*
00178  * Local variables:
00179  * tab-width: 4
00180  * c-basic-offset: 4
00181  * indent-tabs-mode: t
00182  * End:
00183  * vim600: noet sw=4 ts=4 fdm=marker
00184  * vim<600: noet sw=4 ts=4
00185  */