PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LCOV - code coverage report
Current view: top level - ext/mysqli - mysqli_exception.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 16 17 94.1 %
Date: 2014-09-19 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :   +----------------------------------------------------------------------+
       3             :   | PHP Version 5                                                        |
       4             :   +----------------------------------------------------------------------+
       5             :   | Copyright (c) 1997-2014 The PHP Group                                |
       6             :   +----------------------------------------------------------------------+
       7             :   | This source file is subject to version 3.01 of the PHP license,      |
       8             :   | that is bundled with this package in the file LICENSE, and is        |
       9             :   | available through the world-wide-web at the following url:           |
      10             :   | http://www.php.net/license/3_01.txt                                  |
      11             :   | If you did not receive a copy of the PHP license and are unable to   |
      12             :   | obtain it through the world-wide-web, please send a note to          |
      13             :   | license@php.net so we can mail you a copy immediately.               |
      14             :   +----------------------------------------------------------------------+
      15             :   | Author: Georg Richter <georg@php.net>                                |
      16             :   +----------------------------------------------------------------------+
      17             : 
      18             : */
      19             : #ifdef HAVE_CONFIG_H
      20             : #include "config.h"
      21             : #endif
      22             : 
      23             : #include <signal.h>
      24             : 
      25             : #include "php.h"
      26             : #include "php_ini.h"
      27             : #include "ext/standard/info.h"
      28             : #include "php_mysqli_structs.h"
      29             : #include "mysqli_priv.h"
      30             : #include "zend_exceptions.h"
      31             : 
      32             : /* {{{ mysqli_exception_methods[]
      33             :  */
      34             : const zend_function_entry mysqli_exception_methods[] = {
      35             :         {NULL, NULL, NULL}
      36             : };
      37             : /* }}} */
      38             : 
      39          43 : void php_mysqli_throw_sql_exception(char *sqlstate, int errorno TSRMLS_DC, char *format, ...)
      40             : {
      41             :         zval    sql_ex;
      42             :         va_list arg;
      43             :         char    *message;
      44             : 
      45          43 :         va_start(arg, format);
      46          43 :         vspprintf(&message, 0, format, arg);
      47          43 :         va_end(arg);;
      48             : 
      49          43 :         if (!(MyG(report_mode) & MYSQLI_REPORT_STRICT)) {
      50          37 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "(%s/%d): %s", sqlstate, errorno, message);
      51          37 :                 efree(message);
      52          37 :                 return;
      53             :         }
      54             : 
      55           6 :         object_init_ex(&sql_ex, mysqli_exception_class_entry);
      56             : 
      57           6 :         if (message) {
      58           6 :                 zend_update_property_string(mysqli_exception_class_entry, &sql_ex, "message", sizeof("message") - 1,
      59             :                                                                         message TSRMLS_CC);
      60             :         }
      61             : 
      62           6 :         if (sqlstate) {
      63           6 :                 zend_update_property_string(mysqli_exception_class_entry, &sql_ex, "sqlstate", sizeof("sqlstate") - 1,
      64             :                                                                         sqlstate TSRMLS_CC);
      65             :         } else {
      66           0 :                 zend_update_property_string(mysqli_exception_class_entry, &sql_ex, "sqlstate", sizeof("sqlstate") - 1,
      67             :                                                                         "00000" TSRMLS_CC);
      68             :         }
      69             : 
      70           6 :         efree(message);
      71           6 :         zend_update_property_long(mysqli_exception_class_entry, &sql_ex, "code", sizeof("code") - 1, errorno TSRMLS_CC);
      72             : 
      73           6 :         zend_throw_exception_object(&sql_ex TSRMLS_CC);
      74             : }
      75             : 
      76             : /*
      77             :  * Local variables:
      78             :  * tab-width: 4
      79             :  * c-basic-offset: 4
      80             :  * indent-tabs-mode: t
      81             :  * End:
      82             :  * vim600: noet sw=4 ts=4 fdm=marker
      83             :  * vim<600: noet sw=4 ts=4
      84             :  */

Generated by: LCOV version 1.10

Generated at Fri, 19 Sep 2014 17:11:10 +0000 (2 days ago)

Copyright © 2005-2014 The PHP Group
All rights reserved.