Back to index

php5  5.3.10
mysqli_report.c
Go to the documentation of this file.
00001 /*
00002   +----------------------------------------------------------------------+
00003   | PHP Version 5                                                        |
00004   +----------------------------------------------------------------------+
00005   | Copyright (c) 1997-2012 The PHP Group                                |
00006   +----------------------------------------------------------------------+
00007   | This source file is subject to version 3.01 of the PHP license,      |
00008   | that is bundled with this package in the file LICENSE, and is        |
00009   | available through the world-wide-web at the following url:           |
00010   | http://www.php.net/license/3_01.txt                                  |
00011   | If you did not receive a copy of the PHP license and are unable to   |
00012   | obtain it through the world-wide-web, please send a note to          |
00013   | license@php.net so we can mail you a copy immediately.               |
00014   +----------------------------------------------------------------------+
00015   | Author: Georg Richter <georg@php.net>                                |
00016   +----------------------------------------------------------------------+
00017 
00018   $Id: mysqli_report.c 321634 2012-01-01 13:15:04Z felipe $
00019 */
00020 
00021 #ifdef HAVE_CONFIG_H
00022 #include "config.h"
00023 #endif
00024 
00025 #include "php.h"
00026 #include "php_ini.h"
00027 #include "ext/standard/info.h"
00028 #include "php_mysqli_structs.h"
00029 
00030 extern void php_mysqli_throw_sql_exception(char *sqlstate, int errorno TSRMLS_DC, char *format, ...);
00031 
00032 /* {{{ proto bool mysqli_report(int flags)
00033    sets report level */
00034 PHP_FUNCTION(mysqli_report)
00035 {
00036        long flags;
00037 
00038 
00039        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &flags) == FAILURE) {
00040               return;
00041        }
00042 
00043        MyG(report_mode) = flags;
00044 
00045        RETURN_TRUE;
00046 }
00047 /* }}} */
00048 
00049 /* {{{ void php_mysqli_report_error(char *sqlstate, int errorno, char *error) */
00050 void php_mysqli_report_error(const char *sqlstate, int errorno, const char *error TSRMLS_DC)
00051 {
00052        php_mysqli_throw_sql_exception((char *)sqlstate, errorno TSRMLS_CC, "%s", error);
00053 }
00054 /* }}} */
00055 
00056 /* {{{ void php_mysqli_report_index() */
00057 void php_mysqli_report_index(const char *query, unsigned int status TSRMLS_DC) {
00058        char index[15];
00059 
00060        if (status & SERVER_QUERY_NO_GOOD_INDEX_USED) {
00061               strcpy(index, "Bad index");
00062        } else if (status & SERVER_QUERY_NO_INDEX_USED) {
00063               strcpy(index, "No index");
00064        } else {
00065               return;
00066        }
00067        php_mysqli_throw_sql_exception("00000", 0 TSRMLS_CC, "%s used in query/prepared statement %s", index, query);
00068 }
00069 /* }}} */
00070 
00071 /*
00072  * Local variables:
00073  * tab-width: 4
00074  * c-basic-offset: 4
00075  * End:
00076  * vim600: noet sw=4 ts=4 fdm=marker
00077  * vim<600: noet sw=4 ts=4
00078  */