xref: /PHP-7.3/ext/pdo_pgsql/pdo_pgsql.c (revision 25c35ab3)
1 /*
2   +----------------------------------------------------------------------+
3   | PHP Version 7                                                        |
4   +----------------------------------------------------------------------+
5   | Copyright (c) 1997-2018 The PHP Group                                |
6   +----------------------------------------------------------------------+
7   | This source file is subject to version 3.01 of the PHP license,      |
8   | that is bundled with this package in the file LICENSE, and is        |
9   | available through the world-wide-web at the following url:           |
10   | http://www.php.net/license/3_01.txt                                  |
11   | If you did not receive a copy of the PHP license and are unable to   |
12   | obtain it through the world-wide-web, please send a note to          |
13   | license@php.net so we can mail you a copy immediately.               |
14   +----------------------------------------------------------------------+
15   | Author: Edin Kadribasic <edink@emini.dk>                             |
16   +----------------------------------------------------------------------+
17 */
18 
19 #ifdef HAVE_CONFIG_H
20 #include "config.h"
21 #endif
22 
23 #include "php.h"
24 #include "php_ini.h"
25 #include "ext/standard/info.h"
26 #include "pdo/php_pdo.h"
27 #include "pdo/php_pdo_driver.h"
28 #include "php_pdo_pgsql.h"
29 #include "php_pdo_pgsql_int.h"
30 
31 #ifdef HAVE_PG_CONFIG_H
32 #undef PACKAGE_BUGREPORT
33 #undef PACKAGE_NAME
34 #undef PACKAGE_STRING
35 #undef PACKAGE_TARNAME
36 #undef PACKAGE_VERSION
37 #include <pg_config.h>
38 #endif
39 
40 /* {{{ pdo_pgsql_functions[] */
41 static const zend_function_entry pdo_pgsql_functions[] = {
42 	PHP_FE_END
43 };
44 /* }}} */
45 
46 /* {{{ pdo_sqlite_deps
47  */
48 static const zend_module_dep pdo_pgsql_deps[] = {
49 	ZEND_MOD_REQUIRED("pdo")
50 	ZEND_MOD_END
51 };
52 /* }}} */
53 
54 /* {{{ pdo_pgsql_module_entry */
55 zend_module_entry pdo_pgsql_module_entry = {
56 	STANDARD_MODULE_HEADER_EX, NULL,
57 	pdo_pgsql_deps,
58 	"pdo_pgsql",
59 	pdo_pgsql_functions,
60 	PHP_MINIT(pdo_pgsql),
61 	PHP_MSHUTDOWN(pdo_pgsql),
62 	NULL,
63 	NULL,
64 	PHP_MINFO(pdo_pgsql),
65 	PHP_PDO_PGSQL_VERSION,
66 	STANDARD_MODULE_PROPERTIES
67 };
68 /* }}} */
69 
70 #ifdef COMPILE_DL_PDO_PGSQL
71 ZEND_GET_MODULE(pdo_pgsql)
72 #endif
73 
74 /* true global environment */
75 
76 /* {{{ PHP_MINIT_FUNCTION
77  */
PHP_MINIT_FUNCTION(pdo_pgsql)78 PHP_MINIT_FUNCTION(pdo_pgsql)
79 {
80 	REGISTER_PDO_CLASS_CONST_LONG("PGSQL_ATTR_DISABLE_PREPARES", PDO_PGSQL_ATTR_DISABLE_PREPARES);
81 	REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_IDLE", (zend_long)PGSQL_TRANSACTION_IDLE);
82 	REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_ACTIVE", (zend_long)PGSQL_TRANSACTION_ACTIVE);
83 	REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_INTRANS", (zend_long)PGSQL_TRANSACTION_INTRANS);
84 	REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_INERROR", (zend_long)PGSQL_TRANSACTION_INERROR);
85 	REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_UNKNOWN", (zend_long)PGSQL_TRANSACTION_UNKNOWN);
86 
87 	php_pdo_register_driver(&pdo_pgsql_driver);
88 	return SUCCESS;
89 }
90 /* }}} */
91 
92 /* {{{ PHP_MSHUTDOWN_FUNCTION
93  */
PHP_MSHUTDOWN_FUNCTION(pdo_pgsql)94 PHP_MSHUTDOWN_FUNCTION(pdo_pgsql)
95 {
96 	php_pdo_unregister_driver(&pdo_pgsql_driver);
97 	return SUCCESS;
98 }
99 /* }}} */
100 
101 /* {{{ PHP_MINFO_FUNCTION
102  */
PHP_MINFO_FUNCTION(pdo_pgsql)103 PHP_MINFO_FUNCTION(pdo_pgsql)
104 {
105 	php_info_print_table_start();
106 	php_info_print_table_row(2, "PDO Driver for PostgreSQL", "enabled");
107 #ifdef HAVE_PG_CONFIG_H
108 	php_info_print_table_row(2, "PostgreSQL(libpq) Version", PG_VERSION);
109 #endif
110 	php_info_print_table_end();
111 }
112 /* }}} */
113 
114 /*
115  * Local variables:
116  * tab-width: 4
117  * c-basic-offset: 4
118  * End:
119  * vim600: noet sw=4 ts=4 fdm=marker
120  * vim<600: noet sw=4 ts=4
121  */
122