summaryrefslogtreecommitdiff
path: root/ext/mysqli/mysqli_exception.c
diff options
context:
space:
mode:
authorGeorg Richter <georg@php.net>2005-01-07 14:59:59 +0000
committerGeorg Richter <georg@php.net>2005-01-07 14:59:59 +0000
commit0b4c108bd78fff03e49b0be3934dd3c926fed589 (patch)
tree88ad589275108626383326a4151166524044f366 /ext/mysqli/mysqli_exception.c
parent05adbd51b47b90ebfcfeab7d97f4c2b4d28e4065 (diff)
downloadphp-git-0b4c108bd78fff03e49b0be3934dd3c926fed589.tar.gz
Added new classes:
mysqli_driver mysqli_warning mysqli_exception mysqli_sql_exception Improved embedded server support changed testsuite to work also with embedded server Made statement and resultset classes extendable minor fixes
Diffstat (limited to 'ext/mysqli/mysqli_exception.c')
-rw-r--r--ext/mysqli/mysqli_exception.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/ext/mysqli/mysqli_exception.c b/ext/mysqli/mysqli_exception.c
new file mode 100644
index 0000000000..3d1732356b
--- /dev/null
+++ b/ext/mysqli/mysqli_exception.c
@@ -0,0 +1,74 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2004 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.0 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_0.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Author: Georg Richter <georg@php.net> |
+ +----------------------------------------------------------------------+
+
+*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <signal.h>
+
+#include "php.h"
+#include "php_ini.h"
+#include "ext/standard/info.h"
+#include "php_mysqli.h"
+#include "zend_exceptions.h"
+
+/* {{{ mysqli_exception_methods[]
+ */
+function_entry mysqli_exception_methods[] = {
+ {NULL, NULL, NULL}
+};
+/* }}} */
+
+void php_mysqli_throw_sql_exception(char *sqlstate, int errorno TSRMLS_DC, char *format, ...)
+{
+ zval *sql_ex;
+ va_list arg;
+ char *message;
+
+ va_start(arg, format);
+ zend_vspprintf(&message, 0, format, arg);
+ va_end(arg);;
+
+ if (!(MyG(report_mode) & MYSQLI_REPORT_STRICT)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "(%s/%d): %s", sqlstate, errorno, message);
+ return;
+ }
+
+ MAKE_STD_ZVAL(sql_ex);
+ object_init_ex(sql_ex, mysqli_exception_class_entry);
+
+ if (message) {
+ zend_update_property_string(mysqli_exception_class_entry, sql_ex, "message", sizeof("message") - 1,
+ message TSRMLS_CC);
+ }
+
+ if (sqlstate) {
+ zend_update_property_string(mysqli_exception_class_entry, sql_ex, "sqlstate", sizeof("sqlstate") - 1,
+ sqlstate TSRMLS_CC);
+ } else {
+ zend_update_property_string(mysqli_exception_class_entry, sql_ex, "sqlstate", sizeof("sqlstate") - 1,
+ "00000" TSRMLS_CC);
+ }
+
+ efree(message);
+ zend_update_property_long(mysqli_exception_class_entry, sql_ex, "code", sizeof("code") - 1, errorno TSRMLS_CC);
+
+ zend_throw_exception_object(sql_ex);
+}
+