Back to index

php5  5.3.10
php_pdo_mysql_int.h
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   |         Wez Furlong <wez@php.net>                                    |
00017   |         Johannes Schlueter <johannes@mysql.com>                      |
00018   +----------------------------------------------------------------------+
00019 */
00020 
00021 /* $Id: php_pdo_mysql_int.h 321634 2012-01-01 13:15:04Z felipe $ */
00022 
00023 #ifndef PHP_PDO_MYSQL_INT_H
00024 #define PHP_PDO_MYSQL_INT_H
00025 
00026 #if defined(PDO_USE_MYSQLND)
00027 #      include "ext/mysqlnd/mysqlnd.h"
00028 #      include "ext/mysqlnd/mysqlnd_libmysql_compat.h"
00029 #      define PDO_MYSQL_PARAM_BIND MYSQLND_PARAM_BIND
00030 #else
00031 #      include <mysql.h>
00032 #      define PDO_MYSQL_PARAM_BIND MYSQL_BIND
00033 #endif
00034 
00035 #if (MYSQL_VERSION_ID >= 40113 && MYSQL_VERSION_ID < 50000) || MYSQL_VERSION_ID >= 50007 || defined(MYSQL_USE_MYSQLND)
00036 # define PDO_MYSQL_HAS_CHARSET
00037 #endif
00038 
00039 #if defined(PDO_USE_MYSQLND) && PHP_DEBUG && !defined(PHP_WIN32)
00040 #define PDO_DBG_ENABLED 1
00041 
00042 #define PDO_DBG_INF(msg) do { if (dbg_skip_trace == FALSE) PDO_MYSQL_G(dbg)->m->log(PDO_MYSQL_G(dbg), __LINE__, __FILE__, -1, "info : ", (msg)); } while (0)
00043 #define PDO_DBG_ERR(msg) do { if (dbg_skip_trace == FALSE) PDO_MYSQL_G(dbg)->m->log(PDO_MYSQL_G(dbg), __LINE__, __FILE__, -1, "error: ", (msg)); } while (0)
00044 #define PDO_DBG_INF_FMT(...) do { if (dbg_skip_trace == FALSE) PDO_MYSQL_G(dbg)->m->log_va(PDO_MYSQL_G(dbg), __LINE__, __FILE__, -1, "info : ", __VA_ARGS__); } while (0)
00045 #define PDO_DBG_ERR_FMT(...) do { if (dbg_skip_trace == FALSE) PDO_MYSQL_G(dbg)->m->log_va(PDO_MYSQL_G(dbg), __LINE__, __FILE__, -1, "error: ", __VA_ARGS__); } while (0)
00046 #define PDO_DBG_ENTER(func_name) zend_bool dbg_skip_trace = TRUE; if (PDO_MYSQL_G(dbg)) dbg_skip_trace = !PDO_MYSQL_G(dbg)->m->func_enter(PDO_MYSQL_G(dbg), __LINE__, __FILE__, func_name, strlen(func_name));
00047 #define PDO_DBG_RETURN(value)      do { if (PDO_MYSQL_G(dbg)) PDO_MYSQL_G(dbg)->m->func_leave(PDO_MYSQL_G(dbg), __LINE__, __FILE__, 0); return (value); } while (0)
00048 #define PDO_DBG_VOID_RETURN        do { if (PDO_MYSQL_G(dbg)) PDO_MYSQL_G(dbg)->m->func_leave(PDO_MYSQL_G(dbg), __LINE__, __FILE__, 0); return; } while (0)
00049 
00050 #else
00051 #define PDO_DBG_ENABLED 0
00052 
00053 static inline void PDO_DBG_INF(char *msg) {}
00054 static inline void PDO_DBG_ERR(char *msg) {}
00055 static inline void PDO_DBG_INF_FMT(char *format, ...) {}
00056 static inline void PDO_DBG_ERR_FMT(char *format, ...) {}
00057 static inline void PDO_DBG_ENTER(char *func_name) {}
00058 #define PDO_DBG_RETURN(value)      return (value)
00059 #define PDO_DBG_VOID_RETURN        return;
00060 
00061 #endif
00062 
00063 #if defined(PDO_USE_MYSQLND)
00064 #include "ext/mysqlnd/mysqlnd_debug.h"
00065 #endif
00066 
00067 ZEND_BEGIN_MODULE_GLOBALS(pdo_mysql)
00068 #ifndef PHP_WIN32
00069        char          *default_socket;
00070 #endif
00071 #if PDO_DBG_ENABLED
00072        char          *debug; /* The actual string */
00073        MYSQLND_DEBUG *dbg;  /* The DBG object */
00074 #endif
00075 #if defined(PHP_WIN32) && !PDO_DBG_ENABLED
00076        /* dummy member so we get at least one member in the struct
00077         * and avoids build errors.
00078         */
00079        void *dummymemmber;
00080 #endif
00081 ZEND_END_MODULE_GLOBALS(pdo_mysql)
00082 
00083 ZEND_EXTERN_MODULE_GLOBALS(pdo_mysql)
00084 
00085 #ifdef ZTS
00086 #define PDO_MYSQL_G(v) TSRMG(pdo_mysql_globals_id, zend_pdo_mysql_globals *, v)
00087 #else
00088 #define PDO_MYSQL_G(v) (pdo_mysql_globals.v)
00089 #endif
00090 
00091 
00092 typedef struct {
00093        const char *file;
00094        int line;
00095        unsigned int errcode;
00096        char *errmsg;
00097 } pdo_mysql_error_info;
00098 
00099 /* stuff we use in a mySQL database handle */
00100 typedef struct {
00101        MYSQL         *server;
00102 
00103        unsigned attached:1;
00104        unsigned buffered:1;
00105        unsigned emulate_prepare:1;
00106        unsigned fetch_table_names:1;
00107        unsigned _reserved:31;      
00108 #if !PDO_USE_MYSQLND
00109        unsigned long max_buffer_size;
00110 #endif
00111 
00112        pdo_mysql_error_info einfo;
00113 } pdo_mysql_db_handle;
00114 
00115 typedef struct {
00116        MYSQL_FIELD          *def;
00117 } pdo_mysql_column;
00118 
00119 typedef struct {
00120        pdo_mysql_db_handle  *H;
00121        MYSQL_RES            *result;
00122        const MYSQL_FIELD    *fields;
00123        MYSQL_ROW            current_data;
00124 #if PDO_USE_MYSQLND
00125        unsigned long        *current_lengths;
00126 #else
00127        long                 *current_lengths;
00128 #endif
00129        pdo_mysql_error_info einfo;
00130 #if HAVE_MYSQL_STMT_PREPARE || PDO_USE_MYSQLND
00131 #if PDO_USE_MYSQLND
00132        MYSQLND_STMT         *stmt;
00133 #else
00134        MYSQL_STMT           *stmt;
00135 #endif 
00136        int num_params;
00137        PDO_MYSQL_PARAM_BIND *params;
00138 #ifndef PDO_USE_MYSQLND
00139        my_bool                     *in_null;
00140        unsigned long        *in_length;
00141 #endif
00142        PDO_MYSQL_PARAM_BIND *bound_result;
00143        my_bool                     *out_null;
00144        unsigned long        *out_length;
00145        unsigned int         params_given;
00146        unsigned             max_length:1;
00147 #endif
00148 } pdo_mysql_stmt;
00149 
00150 extern pdo_driver_t pdo_mysql_driver;
00151 
00152 extern int _pdo_mysql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *file, int line TSRMLS_DC);
00153 #define pdo_mysql_error(s) _pdo_mysql_error(s, NULL, __FILE__, __LINE__ TSRMLS_CC)
00154 #define pdo_mysql_error_stmt(s) _pdo_mysql_error(stmt->dbh, stmt, __FILE__, __LINE__ TSRMLS_CC)
00155 
00156 extern struct pdo_stmt_methods mysql_stmt_methods;
00157 
00158 enum {
00159        PDO_MYSQL_ATTR_USE_BUFFERED_QUERY = PDO_ATTR_DRIVER_SPECIFIC,
00160        PDO_MYSQL_ATTR_LOCAL_INFILE,
00161        PDO_MYSQL_ATTR_INIT_COMMAND,
00162 #ifndef PDO_USE_MYSQLND
00163        PDO_MYSQL_ATTR_READ_DEFAULT_FILE,
00164        PDO_MYSQL_ATTR_READ_DEFAULT_GROUP,
00165        PDO_MYSQL_ATTR_MAX_BUFFER_SIZE,
00166        PDO_MYSQL_ATTR_COMPRESS,
00167 #endif
00168        PDO_MYSQL_ATTR_DIRECT_QUERY,
00169        PDO_MYSQL_ATTR_FOUND_ROWS,
00170        PDO_MYSQL_ATTR_IGNORE_SPACE,
00171        PDO_MYSQL_ATTR_SSL_KEY,
00172        PDO_MYSQL_ATTR_SSL_CERT,
00173        PDO_MYSQL_ATTR_SSL_CA,
00174        PDO_MYSQL_ATTR_SSL_CAPATH,
00175        PDO_MYSQL_ATTR_SSL_CIPHER
00176 };
00177 
00178 #endif