xref: /PHP-8.1/ext/pdo_pgsql/pdo_pgsql.c (revision 01b3fc03)
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: Edin Kadribasic <edink@emini.dk>                             |
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 "pdo/php_pdo.h"
25 #include "pdo/php_pdo_driver.h"
26 #include "php_pdo_pgsql.h"
27 #include "php_pdo_pgsql_int.h"
28 
29 /* {{{ pdo_sqlite_deps */
30 static const zend_module_dep pdo_pgsql_deps[] = {
31 	ZEND_MOD_REQUIRED("pdo")
32 	ZEND_MOD_END
33 };
34 /* }}} */
35 
36 /* {{{ pdo_pgsql_module_entry */
37 zend_module_entry pdo_pgsql_module_entry = {
38 	STANDARD_MODULE_HEADER_EX, NULL,
39 	pdo_pgsql_deps,
40 	"pdo_pgsql",
41 	NULL,
42 	PHP_MINIT(pdo_pgsql),
43 	PHP_MSHUTDOWN(pdo_pgsql),
44 	NULL,
45 	NULL,
46 	PHP_MINFO(pdo_pgsql),
47 	PHP_PDO_PGSQL_VERSION,
48 	STANDARD_MODULE_PROPERTIES
49 };
50 /* }}} */
51 
52 #ifdef COMPILE_DL_PDO_PGSQL
53 ZEND_GET_MODULE(pdo_pgsql)
54 #endif
55 
56 /* true global environment */
57 
58 /* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(pdo_pgsql)59 PHP_MINIT_FUNCTION(pdo_pgsql)
60 {
61 	REGISTER_PDO_CLASS_CONST_LONG("PGSQL_ATTR_DISABLE_PREPARES", PDO_PGSQL_ATTR_DISABLE_PREPARES);
62 	REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_IDLE", (zend_long)PGSQL_TRANSACTION_IDLE);
63 	REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_ACTIVE", (zend_long)PGSQL_TRANSACTION_ACTIVE);
64 	REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_INTRANS", (zend_long)PGSQL_TRANSACTION_INTRANS);
65 	REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_INERROR", (zend_long)PGSQL_TRANSACTION_INERROR);
66 	REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_UNKNOWN", (zend_long)PGSQL_TRANSACTION_UNKNOWN);
67 
68 	return php_pdo_register_driver(&pdo_pgsql_driver);
69 }
70 /* }}} */
71 
72 /* {{{ PHP_MSHUTDOWN_FUNCTION */
PHP_MSHUTDOWN_FUNCTION(pdo_pgsql)73 PHP_MSHUTDOWN_FUNCTION(pdo_pgsql)
74 {
75 	php_pdo_unregister_driver(&pdo_pgsql_driver);
76 	return SUCCESS;
77 }
78 /* }}} */
79 
80 /* {{{ PHP_MINFO_FUNCTION */
PHP_MINFO_FUNCTION(pdo_pgsql)81 PHP_MINFO_FUNCTION(pdo_pgsql)
82 {
83 	char buf[16];
84 
85 	php_info_print_table_start();
86 	php_info_print_table_row(2, "PDO Driver for PostgreSQL", "enabled");
87 	pdo_libpq_version(buf, sizeof(buf));
88 	php_info_print_table_row(2, "PostgreSQL(libpq) Version", buf);
89 	php_info_print_table_end();
90 }
91 /* }}} */
92