php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
pdo_odbc.c
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | Copyright (c) The PHP Group |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.01 of the PHP license, |
6 | that is bundled with this package in the file LICENSE, and is |
7 | available through the world-wide-web at the following url: |
8 | https://www.php.net/license/3_01.txt |
9 | If you did not receive a copy of the PHP license and are unable to |
10 | obtain it through the world-wide-web, please send a note to |
11 | license@php.net so we can mail you a copy immediately. |
12 +----------------------------------------------------------------------+
13 | Author: Wez Furlong <wez@php.net> |
14 +----------------------------------------------------------------------+
15*/
16
17#ifdef HAVE_CONFIG_H
18#include <config.h>
19#endif
20
21#include "php.h"
22#include "php_ini.h"
23#include "ext/standard/info.h"
24#include "ext/pdo/php_pdo.h"
26#include "php_pdo_odbc.h"
27#include "php_pdo_odbc_int.h"
28#include "pdo_odbc_arginfo.h"
29
30static zend_class_entry *pdo_odbc_ce;
31
32/* {{{ pdo_odbc_deps[] */
33static const zend_module_dep pdo_odbc_deps[] = {
36};
37/* }}} */
38
39/* {{{ pdo_odbc_module_entry */
42 pdo_odbc_deps,
43 "PDO_ODBC",
44 NULL,
45 PHP_MINIT(pdo_odbc),
46 PHP_MSHUTDOWN(pdo_odbc),
47 NULL,
48 NULL,
49 PHP_MINFO(pdo_odbc),
52};
53/* }}} */
54
55#ifdef COMPILE_DL_PDO_ODBC
56ZEND_GET_MODULE(pdo_odbc)
57#endif
58
59#ifdef SQL_ATTR_CONNECTION_POOLING
60zend_ulong pdo_odbc_pool_on = SQL_CP_OFF;
61zend_ulong pdo_odbc_pool_mode = SQL_CP_ONE_PER_HENV;
62#endif
63
64/* {{{ PHP_MINIT_FUNCTION */
66{
67#ifdef SQL_ATTR_CONNECTION_POOLING
68 char *pooling_val = NULL;
69#endif
70
72 return FAILURE;
73 }
74
75#ifdef SQL_ATTR_CONNECTION_POOLING
76 /* ugh, we don't really like .ini stuff in PDO, but since ODBC connection
77 * pooling is process wide, we can't set it from within the scope of a
78 * request without affecting others, which goes against our isolated request
79 * policy. So, we use cfg_get_string here to check it this once.
80 * */
81 if (FAILURE == cfg_get_string("pdo_odbc.connection_pooling", &pooling_val) || pooling_val == NULL) {
82 pooling_val = "strict";
83 }
84 if (strcasecmp(pooling_val, "strict") == 0 || strcmp(pooling_val, "1") == 0) {
85 pdo_odbc_pool_on = SQL_CP_ONE_PER_HENV;
86 pdo_odbc_pool_mode = SQL_CP_STRICT_MATCH;
87 } else if (strcasecmp(pooling_val, "relaxed") == 0) {
88 pdo_odbc_pool_on = SQL_CP_ONE_PER_HENV;
89 pdo_odbc_pool_mode = SQL_CP_RELAXED_MATCH;
90 } else if (*pooling_val == '\0' || strcasecmp(pooling_val, "off") == 0) {
91 pdo_odbc_pool_on = SQL_CP_OFF;
92 } else {
93 php_error_docref(NULL, E_CORE_ERROR, "Error in pdo_odbc.connection_pooling configuration. Value must be one of \"strict\", \"relaxed\", or \"off\"");
94 return FAILURE;
95 }
96
97 if (pdo_odbc_pool_on != SQL_CP_OFF) {
98 SQLSetEnvAttr(SQL_NULL_HANDLE, SQL_ATTR_CONNECTION_POOLING, (void*)pdo_odbc_pool_on, 0);
99 }
100#endif
101
102 register_pdo_odbc_symbols(module_number);
103
106 REGISTER_PDO_CLASS_CONST_LONG("ODBC_SQL_USE_IF_NEEDED", SQL_CUR_USE_IF_NEEDED);
109
110 pdo_odbc_ce = register_class_Pdo_Odbc(pdo_dbh_ce);
111 pdo_odbc_ce->create_object = pdo_dbh_new;
112
114}
115/* }}} */
116
117/* {{{ PHP_MSHUTDOWN_FUNCTION */
123/* }}} */
124
125/* {{{ PHP_MINFO_FUNCTION */
127{
129 php_info_print_table_row(2, "PDO Driver for ODBC (" PDO_ODBC_TYPE ")" , "enabled");
130#ifdef SQL_ATTR_CONNECTION_POOLING
131 php_info_print_table_row(2, "ODBC Connection Pooling", pdo_odbc_pool_on == SQL_CP_OFF ?
132 "Disabled" : (pdo_odbc_pool_mode == SQL_CP_STRICT_MATCH ? "Enabled, strict matching" : "Enabled, relaxed matching"));
133#else
134 php_info_print_table_row(2, "ODBC Connection Pooling", "Not supported in this build");
135#endif
137}
138/* }}} */
#define NULL
Definition gdcache.h:45
#define SUCCESS
Definition hash_sha3.c:261
PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format,...)
Definition main.c:1173
const SQL_CUR_USE_IF_NEEDED
Definition odbc.stub.php:61
const SQL_CUR_USE_DRIVER
Definition odbc.stub.php:56
const SQL_CUR_USE_ODBC
Definition odbc.stub.php:66
const pdo_driver_t pdo_odbc_driver
PDO_API void php_pdo_unregister_driver(const pdo_driver_t *driver)
Definition pdo.c:129
PDO_API zend_result php_pdo_register_driver(const pdo_driver_t *driver)
Definition pdo.c:113
PDO_API zend_result php_pdo_register_driver_specific_ce(const pdo_driver_t *driver, zend_class_entry *ce)
Definition pdo.c:140
zend_class_entry * pdo_dbh_ce
Definition pdo.c:34
zend_object * pdo_dbh_new(zend_class_entry *ce)
Definition pdo_dbh.c:1533
php_info_print_table_start()
Definition info.c:1064
php_info_print_table_row(2, "PDO Driver for Firebird", "enabled")
php_info_print_table_end()
Definition info.c:1074
zend_module_entry pdo_odbc_module_entry
Definition pdo_odbc.c:40
#define PHP_MSHUTDOWN_FUNCTION
Definition php.h:401
#define PHP_MINFO
Definition php.h:396
#define PHP_MINIT_FUNCTION
Definition php.h:400
#define PHP_MSHUTDOWN
Definition php.h:393
#define PHP_MINFO_FUNCTION
Definition php.h:404
#define PHP_MINIT
Definition php.h:392
PHPAPI int cfg_get_string(const char *varname, char **result)
Definition php_ini.c:927
#define REGISTER_PDO_CLASS_CONST_LONG(const_name, value)
Definition php_pdo.h:53
#define PHP_PDO_ODBC_VERSION
@ PDO_ODBC_ATTR_ASSUME_UTF8
@ PDO_ODBC_ATTR_USE_CURSOR_LIBRARY
#define PDO_ODBC_TYPE
#define ZEND_GET_MODULE(name)
Definition zend_API.h:241
strcmp(string $string1, string $string2)
#define strcasecmp(s1, s2)
#define E_CORE_ERROR
Definition zend_errors.h:27
uint32_t zend_ulong
Definition zend_long.h:43
#define ZEND_MOD_END
struct _zend_module_dep zend_module_dep
struct _zend_module_entry zend_module_entry
#define STANDARD_MODULE_PROPERTIES
#define ZEND_MOD_REQUIRED(name)
#define STANDARD_MODULE_HEADER_EX
struct _zend_class_entry zend_class_entry
@ FAILURE
Definition zend_types.h:61