xref: /PHP-8.2/ext/mysqli/mysqli_driver.c (revision 01cbe390)
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: Georg Richter <georg@php.net>                                |
14   +----------------------------------------------------------------------+
15 
16 */
17 #ifdef HAVE_CONFIG_H
18 #include "config.h"
19 #endif
20 
21 #include <signal.h>
22 
23 #include "php.h"
24 #include "php_ini.h"
25 #include "ext/standard/info.h"
26 #include "php_mysqli_structs.h"
27 #include "zend_exceptions.h"
28 
29 
30 /* {{{ property driver_report_read */
driver_report_read(mysqli_object * obj,zval * retval,bool quiet)31 static int driver_report_read(mysqli_object *obj, zval *retval, bool quiet)
32 {
33 	ZVAL_LONG(retval, MyG(report_mode));
34 	return SUCCESS;
35 }
36 /* }}} */
37 
38 /* {{{ property driver_report_write */
driver_report_write(mysqli_object * obj,zval * value)39 static int driver_report_write(mysqli_object *obj, zval *value)
40 {
41 	ZEND_ASSERT(Z_TYPE_P(value) == IS_LONG);
42 	MyG(report_mode) = Z_LVAL_P(value);
43 	return SUCCESS;
44 }
45 /* }}} */
46 
47 /* {{{ property driver_client_version_read */
driver_client_version_read(mysqli_object * obj,zval * retval,bool quiet)48 static int driver_client_version_read(mysqli_object *obj, zval *retval, bool quiet)
49 {
50 	ZVAL_LONG(retval, mysql_get_client_version());
51 	return SUCCESS;
52 }
53 /* }}} */
54 
55 /* {{{ property driver_client_info_read */
driver_client_info_read(mysqli_object * obj,zval * retval,bool quiet)56 static int driver_client_info_read(mysqli_object *obj, zval *retval, bool quiet)
57 {
58 	ZVAL_STRING(retval, (char *)mysql_get_client_info());
59 	return SUCCESS;
60 }
61 /* }}} */
62 
63 /* {{{ property driver_driver_version_read */
driver_driver_version_read(mysqli_object * obj,zval * retval,bool quiet)64 static int driver_driver_version_read(mysqli_object *obj, zval *retval, bool quiet)
65 {
66 	if (quiet) {
67 		return FAILURE;
68 	}
69 	zend_error(E_DEPRECATED, "The driver_version property is deprecated");
70 	ZVAL_LONG(retval, MYSQLI_VERSION_ID);
71 	return SUCCESS;
72 }
73 /* }}} */
74 
75 const mysqli_property_entry mysqli_driver_property_entries[] = {
76 	{"client_info", sizeof("client_info") - 1, driver_client_info_read, NULL},
77 	{"client_version", sizeof("client_version") - 1, driver_client_version_read, NULL},
78 	{"driver_version", sizeof("driver_version") - 1, driver_driver_version_read, NULL},
79 	{"report_mode", sizeof("report_mode") - 1, driver_report_read, driver_report_write},
80 	{NULL, 0, NULL, NULL}
81 };
82 
83