Back to index

php5  5.3.10
pdo_mysql.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: George Schlossnagle <george@omniti.com>                      |
00016   |         Johannes Schlueter <johannes@mysql.com>                      |
00017   +----------------------------------------------------------------------+
00018 */
00019 
00020 /* $Id: pdo_mysql.c 321634 2012-01-01 13:15:04Z felipe $ */
00021 
00022 #ifdef HAVE_CONFIG_H
00023 #include "config.h"
00024 #endif
00025 
00026 #include "php.h"
00027 #include "php_ini.h"
00028 #include "ext/standard/info.h"
00029 #include "pdo/php_pdo.h"
00030 #include "pdo/php_pdo_driver.h"
00031 #include "php_pdo_mysql.h"
00032 #include "php_pdo_mysql_int.h"
00033 
00034 #ifdef COMPILE_DL_PDO_MYSQL
00035 ZEND_GET_MODULE(pdo_mysql)
00036 #endif
00037 
00038 ZEND_DECLARE_MODULE_GLOBALS(pdo_mysql);
00039 
00040 /*
00041  The default socket location is sometimes defined by configure.
00042  With libmysql `mysql_config --socket` will fill PDO_MYSQL_UNIX_ADDR
00043  and the user can use --with-mysql-sock=SOCKET which will fill
00044  PDO_MYSQL_UNIX_ADDR. If both aren't set we're using mysqlnd and use
00045  /tmp/mysql.sock as default on *nix and NULL for Windows (default 
00046  named pipe name is set in mysqlnd).
00047 */
00048 #ifndef PDO_MYSQL_UNIX_ADDR
00049 # ifdef PHP_MYSQL_UNIX_SOCK_ADDR
00050 #  define PDO_MYSQL_UNIX_ADDR PHP_MYSQL_UNIX_SOCK_ADDR
00051 # else
00052 #  if !PHP_WIN32
00053 #   define PDO_MYSQL_UNIX_ADDR "/tmp/mysql.sock"
00054 #  else
00055 #   define PDO_MYSQL_UNIX_ADDR NULL
00056 #  endif
00057 # endif
00058 #endif
00059 
00060 /* {{{ PHP_INI_BEGIN
00061 */
00062 PHP_INI_BEGIN()
00063 #ifndef PHP_WIN32
00064        STD_PHP_INI_ENTRY("pdo_mysql.default_socket", PDO_MYSQL_UNIX_ADDR, PHP_INI_SYSTEM, OnUpdateStringUnempty, default_socket, zend_pdo_mysql_globals, pdo_mysql_globals)
00065 #endif
00066 #if PDO_DBG_ENABLED
00067        STD_PHP_INI_ENTRY("pdo_mysql.debug",      NULL, PHP_INI_SYSTEM, OnUpdateString, debug, zend_pdo_mysql_globals, pdo_mysql_globals)
00068 #endif
00069 PHP_INI_END()
00070 /* }}} */
00071 
00072 /* true global environment */             
00073               
00074 /* {{{ PHP_MINIT_FUNCTION
00075  */
00076 static PHP_MINIT_FUNCTION(pdo_mysql)
00077 {
00078        REGISTER_INI_ENTRIES();
00079 
00080        REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_USE_BUFFERED_QUERY", (long)PDO_MYSQL_ATTR_USE_BUFFERED_QUERY);
00081        REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_LOCAL_INFILE", (long)PDO_MYSQL_ATTR_LOCAL_INFILE);      
00082        REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_INIT_COMMAND", (long)PDO_MYSQL_ATTR_INIT_COMMAND);
00083 #ifndef PDO_USE_MYSQLND
00084        REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_MAX_BUFFER_SIZE", (long)PDO_MYSQL_ATTR_MAX_BUFFER_SIZE);
00085        REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_READ_DEFAULT_FILE", (long)PDO_MYSQL_ATTR_READ_DEFAULT_FILE);
00086        REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_READ_DEFAULT_GROUP", (long)PDO_MYSQL_ATTR_READ_DEFAULT_GROUP);
00087        REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_COMPRESS", (long)PDO_MYSQL_ATTR_COMPRESS);
00088 #endif
00089        REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_DIRECT_QUERY", (long)PDO_MYSQL_ATTR_DIRECT_QUERY);
00090        REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_FOUND_ROWS", (long)PDO_MYSQL_ATTR_FOUND_ROWS);
00091        REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_IGNORE_SPACE", (long)PDO_MYSQL_ATTR_IGNORE_SPACE);
00092        REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_KEY", (long)PDO_MYSQL_ATTR_SSL_KEY);
00093        REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CERT", (long)PDO_MYSQL_ATTR_SSL_CERT);
00094        REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CA", (long)PDO_MYSQL_ATTR_SSL_CA);
00095        REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CAPATH", (long)PDO_MYSQL_ATTR_SSL_CAPATH);
00096        REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CIPHER", (long)PDO_MYSQL_ATTR_SSL_CIPHER);
00097        return php_pdo_register_driver(&pdo_mysql_driver);
00098 }
00099 /* }}} */
00100 
00101 /* {{{ PHP_MSHUTDOWN_FUNCTION
00102  */
00103 static PHP_MSHUTDOWN_FUNCTION(pdo_mysql)
00104 {
00105        php_pdo_unregister_driver(&pdo_mysql_driver);
00106 #if PDO_USE_MYSQLND
00107        UNREGISTER_INI_ENTRIES();
00108 #endif
00109 
00110        return SUCCESS;
00111 }
00112 /* }}} */
00113 
00114 /* {{{ PHP_MINFO_FUNCTION
00115  */
00116 static PHP_MINFO_FUNCTION(pdo_mysql)
00117 {
00118        php_info_print_table_start();
00119 
00120        php_info_print_table_header(2, "PDO Driver for MySQL", "enabled");
00121        php_info_print_table_row(2, "Client API version", mysql_get_client_info());
00122 
00123        php_info_print_table_end();
00124 
00125 #ifndef PHP_WIN32
00126        DISPLAY_INI_ENTRIES();
00127 #endif
00128 }
00129 /* }}} */
00130 
00131 
00132 #if PDO_USE_MYSQLND && PDO_DBG_ENABLED
00133 /* {{{ PHP_RINIT_FUNCTION
00134  */
00135 static PHP_RINIT_FUNCTION(pdo_mysql)
00136 {      
00137        if (PDO_MYSQL_G(debug)) {
00138               MYSQLND_DEBUG *dbg = mysqlnd_debug_init(mysqlnd_debug_std_no_trace_funcs TSRMLS_CC);
00139               if (!dbg) {
00140                      return FAILURE;
00141               }
00142               dbg->m->set_mode(dbg, PDO_MYSQL_G(debug));
00143               PDO_MYSQL_G(dbg) = dbg;
00144        }
00145        
00146        return SUCCESS;
00147 }
00148 /* }}} */
00149 
00150 /* {{{ PHP_RSHUTDOWN_FUNCTION
00151  */
00152 static PHP_RSHUTDOWN_FUNCTION(pdo_mysql)
00153 {
00154        MYSQLND_DEBUG *dbg = PDO_MYSQL_G(dbg);
00155        PDO_DBG_ENTER("RSHUTDOWN");
00156        if (dbg) {
00157               dbg->m->close(dbg);
00158               dbg->m->free_handle(dbg);
00159               PDO_MYSQL_G(dbg) = NULL;
00160        }
00161 
00162        return SUCCESS;
00163 }
00164 /* }}} */
00165 #endif
00166 
00167 /* {{{ PHP_GINIT_FUNCTION
00168  */
00169 static PHP_GINIT_FUNCTION(pdo_mysql)
00170 {
00171 #ifndef PHP_WIN32
00172        pdo_mysql_globals->default_socket = NULL;
00173 #endif
00174 #if PDO_DBG_ENABLED
00175        pdo_mysql_globals->debug = NULL;   /* The actual string */
00176        pdo_mysql_globals->dbg = NULL;     /* The DBG object*/
00177 #endif
00178 }
00179 /* }}} */
00180 
00181 /* {{{ pdo_mysql_functions[] */
00182 const zend_function_entry pdo_mysql_functions[] = {
00183        PHP_FE_END
00184 };
00185 /* }}} */
00186 
00187 /* {{{ pdo_mysql_deps[] */
00188 #if ZEND_MODULE_API_NO >= 20050922
00189 static const zend_module_dep pdo_mysql_deps[] = {
00190        ZEND_MOD_REQUIRED("pdo")
00191 #ifdef PDO_USE_MYSQLND
00192        ZEND_MOD_REQUIRED("mysqlnd")
00193 #endif
00194        ZEND_MOD_END
00195 };
00196 #endif
00197 /* }}} */
00198 
00199 /* {{{ pdo_mysql_module_entry */
00200 zend_module_entry pdo_mysql_module_entry = {
00201        STANDARD_MODULE_HEADER_EX, NULL,
00202        pdo_mysql_deps,
00203        "pdo_mysql",
00204        pdo_mysql_functions,
00205        PHP_MINIT(pdo_mysql),
00206        PHP_MSHUTDOWN(pdo_mysql),
00207 #if PDO_USE_MYSQLND && PDO_DBG_ENABLED
00208        PHP_RINIT(pdo_mysql),
00209        PHP_RSHUTDOWN(pdo_mysql),
00210 #else
00211        NULL,
00212        NULL,
00213 #endif
00214        PHP_MINFO(pdo_mysql),
00215        "1.0.2",
00216        PHP_MODULE_GLOBALS(pdo_mysql),
00217        PHP_GINIT(pdo_mysql),
00218        NULL,
00219        NULL,
00220        STANDARD_MODULE_PROPERTIES_EX
00221 };
00222 /* }}} */
00223 
00224 
00225 /*
00226  * Local variables:
00227  * tab-width: 4
00228  * c-basic-offset: 4
00229  * End:
00230  * vim600: noet sw=4 ts=4 fdm=marker
00231  * vim<600: noet sw=4 ts=4
00232  */