xref: /PHP-8.1/ext/pdo_sqlite/pdo_sqlite.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: 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 "pdo/php_pdo.h"
25 #include "pdo/php_pdo_driver.h"
26 #include "php_pdo_sqlite.h"
27 #include "php_pdo_sqlite_int.h"
28 #include "zend_exceptions.h"
29 
30 /* {{{ pdo_sqlite_deps */
31 static const zend_module_dep pdo_sqlite_deps[] = {
32 	ZEND_MOD_REQUIRED("pdo")
33 	ZEND_MOD_END
34 };
35 /* }}} */
36 
37 /* {{{ pdo_sqlite_module_entry */
38 zend_module_entry pdo_sqlite_module_entry = {
39 	STANDARD_MODULE_HEADER_EX, NULL,
40 	pdo_sqlite_deps,
41 	"pdo_sqlite",
42 	NULL,
43 	PHP_MINIT(pdo_sqlite),
44 	PHP_MSHUTDOWN(pdo_sqlite),
45 	NULL,
46 	NULL,
47 	PHP_MINFO(pdo_sqlite),
48 	PHP_PDO_SQLITE_VERSION,
49 	STANDARD_MODULE_PROPERTIES
50 };
51 /* }}} */
52 
53 #if defined(COMPILE_DL_PDO_SQLITE) || defined(COMPILE_DL_PDO_SQLITE_EXTERNAL)
54 ZEND_GET_MODULE(pdo_sqlite)
55 #endif
56 
57 /* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(pdo_sqlite)58 PHP_MINIT_FUNCTION(pdo_sqlite)
59 {
60 #ifdef SQLITE_DETERMINISTIC
61 	REGISTER_PDO_CLASS_CONST_LONG("SQLITE_DETERMINISTIC", (zend_long)SQLITE_DETERMINISTIC);
62 #endif
63 
64 	REGISTER_PDO_CLASS_CONST_LONG("SQLITE_ATTR_OPEN_FLAGS", (zend_long)PDO_SQLITE_ATTR_OPEN_FLAGS);
65 	REGISTER_PDO_CLASS_CONST_LONG("SQLITE_OPEN_READONLY", (zend_long)SQLITE_OPEN_READONLY);
66 	REGISTER_PDO_CLASS_CONST_LONG("SQLITE_OPEN_READWRITE", (zend_long)SQLITE_OPEN_READWRITE);
67 	REGISTER_PDO_CLASS_CONST_LONG("SQLITE_OPEN_CREATE", (zend_long)SQLITE_OPEN_CREATE);
68 	REGISTER_PDO_CLASS_CONST_LONG("SQLITE_ATTR_READONLY_STATEMENT", (zend_long)PDO_SQLITE_ATTR_READONLY_STATEMENT);
69 	REGISTER_PDO_CLASS_CONST_LONG("SQLITE_ATTR_EXTENDED_RESULT_CODES", (zend_long)PDO_SQLITE_ATTR_EXTENDED_RESULT_CODES);
70 
71 	return php_pdo_register_driver(&pdo_sqlite_driver);
72 }
73 /* }}} */
74 
75 /* {{{ PHP_MSHUTDOWN_FUNCTION */
PHP_MSHUTDOWN_FUNCTION(pdo_sqlite)76 PHP_MSHUTDOWN_FUNCTION(pdo_sqlite)
77 {
78 	php_pdo_unregister_driver(&pdo_sqlite_driver);
79 	return SUCCESS;
80 }
81 /* }}} */
82 
83 /* {{{ PHP_MINFO_FUNCTION */
PHP_MINFO_FUNCTION(pdo_sqlite)84 PHP_MINFO_FUNCTION(pdo_sqlite)
85 {
86 	php_info_print_table_start();
87 	php_info_print_table_header(2, "PDO Driver for SQLite 3.x", "enabled");
88 	php_info_print_table_row(2, "SQLite Library", sqlite3_libversion());
89 	php_info_print_table_end();
90 }
91 /* }}} */
92