xref: /php-src/ext/pdo/php_pdo.h (revision d6a0b3af)
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 #ifndef PHP_PDO_H
18 #define PHP_PDO_H
19 
20 #include "zend.h"
21 
22 PHPAPI extern zend_module_entry pdo_module_entry;
23 #define phpext_pdo_ptr &pdo_module_entry
24 
25 PHPAPI extern zend_class_entry *pdo_dbh_ce;
26 PHPAPI extern zend_object *pdo_dbh_new(zend_class_entry *ce);
27 
28 #include "php_version.h"
29 #define PHP_PDO_VERSION PHP_VERSION
30 
31 #ifdef PHP_WIN32
32 #	if defined(PDO_EXPORTS) || (!defined(COMPILE_DL_PDO))
33 #		define PDO_API __declspec(dllexport)
34 #	elif defined(COMPILE_DL_PDO)
35 #		define PDO_API __declspec(dllimport)
36 #	else
37 #		define PDO_API /* nothing special */
38 #	endif
39 #elif defined(__GNUC__) && __GNUC__ >= 4
40 #	define PDO_API __attribute__ ((visibility("default")))
41 #else
42 #	define PDO_API /* nothing special */
43 #endif
44 
45 #ifdef ZTS
46 # include "TSRM.h"
47 #endif
48 
49 PHP_MINIT_FUNCTION(pdo);
50 PHP_MSHUTDOWN_FUNCTION(pdo);
51 PHP_MINFO_FUNCTION(pdo);
52 
53 #define REGISTER_PDO_CLASS_CONST_LONG(const_name, value) \
54 	zend_declare_class_constant_long(php_pdo_get_dbh_ce(), const_name, sizeof(const_name)-1, (zend_long)value);
55 
56 #define LONG_CONST(c) (zend_long) c
57 
58 #define PDO_CONSTRUCT_CHECK \
59 	if (!dbh->driver) { \
60 		zend_throw_error(NULL, "%s object is uninitialized", ZSTR_VAL(Z_OBJ(EX(This))->ce->name)); \
61 		RETURN_THROWS(); \
62 	} \
63 
64 
65 #endif	/* PHP_PDO_H */
66