Back to index

php5  5.3.10
Defines | Functions | Variables
mysqli_warning.c File Reference
#include <signal.h>
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_mysqli_structs.h"
#include "mysqli_priv.h"

Go to the source code of this file.

Defines

#define ZSTR_DUPLICATE   (1<<0)
#define ZSTR_AUTOFREE   (1<<1)
#define ZVAL_UTF8_STRING(z, s, flags)   ZVAL_STRING((z), (char*)(s), ((flags) & ZSTR_DUPLICATE))
#define ZVAL_UTF8_STRINGL(z, s, l, flags)   ZVAL_STRINGL((z), (char*)(s), (l), ((flags) & ZSTR_DUPLICATE))

Functions

void php_clear_warnings (MYSQLI_WARNING *w)
static MYSQLI_WARNING * php_new_warning (const char *reason, int errorno TSRMLS_DC)
MYSQLI_WARNING * php_get_warnings (MYSQL *mysql TSRMLS_DC)
 PHP_METHOD (mysqli_warning, next)
static int mysqli_warning_message (mysqli_object *obj, zval **retval TSRMLS_DC)
static int mysqli_warning_sqlstate (mysqli_object *obj, zval **retval TSRMLS_DC)
static int mysqli_warning_errno (mysqli_object *obj, zval **retval TSRMLS_DC)
 PHP_METHOD (mysqli_warning, __construct)

Variables

const zend_function_entry mysqli_warning_methods []
const mysqli_property_entry mysqli_warning_property_entries []
zend_property_info mysqli_warning_property_info_entries []

Define Documentation

#define ZSTR_AUTOFREE   (1<<1)

Definition at line 33 of file mysqli_warning.c.

#define ZSTR_DUPLICATE   (1<<0)

Definition at line 32 of file mysqli_warning.c.

#define ZVAL_UTF8_STRING (   z,
  s,
  flags 
)    ZVAL_STRING((z), (char*)(s), ((flags) & ZSTR_DUPLICATE))

Definition at line 35 of file mysqli_warning.c.

#define ZVAL_UTF8_STRINGL (   z,
  s,
  l,
  flags 
)    ZVAL_STRINGL((z), (char*)(s), (l), ((flags) & ZSTR_DUPLICATE))

Definition at line 36 of file mysqli_warning.c.


Function Documentation

static int mysqli_warning_errno ( mysqli_object obj,
zval **retval  TSRMLS_DC 
) [static]

Definition at line 251 of file mysqli_warning.c.

{
       MYSQLI_WARNING *w;

       if (!obj->ptr || !((MYSQLI_RESOURCE *)(obj->ptr))->ptr) {
              return FAILURE;
       }
       w = (MYSQLI_WARNING *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
       MAKE_STD_ZVAL(*retval);
       ZVAL_LONG(*retval, w->errorno);
       return SUCCESS;
}
static int mysqli_warning_message ( mysqli_object obj,
zval **retval  TSRMLS_DC 
) [static]

Definition at line 213 of file mysqli_warning.c.

{
       MYSQLI_WARNING *w;

       if (!obj->ptr || !((MYSQLI_RESOURCE *)(obj->ptr))->ptr) {
              return FAILURE;
       }

       w = (MYSQLI_WARNING *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
       MAKE_STD_ZVAL(*retval);
       **retval = w->reason;
       zval_copy_ctor(*retval);
       return SUCCESS;
}
static int mysqli_warning_sqlstate ( mysqli_object obj,
zval **retval  TSRMLS_DC 
) [static]

Definition at line 232 of file mysqli_warning.c.

{
       MYSQLI_WARNING *w;

       if (!obj->ptr || !((MYSQLI_RESOURCE *)(obj->ptr))->ptr) {
              return FAILURE;
       }

       w = (MYSQLI_WARNING *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
       MAKE_STD_ZVAL(*retval);
       **retval = w->sqlstate;
       zval_copy_ctor(*retval);
       return SUCCESS;
}
void php_clear_warnings ( MYSQLI_WARNING *  w)

Definition at line 40 of file mysqli_warning.c.

{
       MYSQLI_WARNING *n;

       while (w) {
              n = w;
              zval_dtor(&(w->reason));
              zval_dtor(&(w->sqlstate));
              w = w->next;
              efree(n);
       }
}

Here is the caller graph for this function:

MYSQLI_WARNING* php_get_warnings ( MYSQL *mysql  TSRMLS_DC)

Definition at line 76 of file mysqli_warning.c.

{
       MYSQLI_WARNING *w, *first = NULL, *prev = NULL;
       MYSQL_RES            *result;
       MYSQL_ROW            row;

       if (mysql_real_query(mysql, "SHOW WARNINGS", 13)) {
              return NULL;
       }

       result = mysql_store_result(mysql);

       while ((row = mysql_fetch_row(result))) {
              w = php_new_warning(row[2], atoi(row[1]) TSRMLS_CC);
              if (!first) {
                     first = w;
              }
              if (prev) {
                     prev->next = w;
              }
              prev = w;
       }
       mysql_free_result(result);
       return first;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PHP_METHOD ( mysqli_warning  ,
next   
)

Definition at line 186 of file mysqli_warning.c.

{
       MYSQLI_WARNING       *w;
       zval                 *mysqli_warning;
       mysqli_object *obj = (mysqli_object *)zend_objects_get_address(getThis() TSRMLS_CC);

       if (obj->ptr) {
              if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
                                                                       &mysqli_warning, mysqli_warning_class_entry) == FAILURE) {
                     return;
              }

              MYSQLI_FETCH_RESOURCE(w, MYSQLI_WARNING *, &mysqli_warning, "mysqli_warning", MYSQLI_STATUS_VALID);

              if (w && w->next) {
                     w = w->next;
               ((MYSQLI_RESOURCE *)(obj->ptr))->ptr = w;
                     RETURN_TRUE;
              }
       }
       RETURN_FALSE;
}

Here is the call graph for this function:

PHP_METHOD ( mysqli_warning  ,
__construct   
)

Definition at line 266 of file mysqli_warning.c.

{
       zval                 *z;
       mysqli_object *obj;
       MYSQL                *hdl;
       MYSQLI_WARNING  *w;
       MYSQLI_RESOURCE *mysqli_resource;

       if (ZEND_NUM_ARGS() != 1) {
              WRONG_PARAM_COUNT;
       }
       if (zend_parse_parameters(1 TSRMLS_CC, "o", &z)==FAILURE) {
              return;
       }
       obj = (mysqli_object *)zend_object_store_get_object(z TSRMLS_CC);\

       if (obj->zo.ce == mysqli_link_class_entry) {
              MY_MYSQL *mysql;
              MYSQLI_FETCH_RESOURCE_CONN(mysql, &z, MYSQLI_STATUS_VALID);
              hdl = mysql->mysql;
       } else if (obj->zo.ce == mysqli_stmt_class_entry) {
              MY_STMT *stmt;
              MYSQLI_FETCH_RESOURCE_STMT(stmt, &z, MYSQLI_STATUS_VALID);
              hdl = mysqli_stmt_get_connection(stmt->stmt);
       } else {
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid class argument");
              RETURN_FALSE;
       }

       if (mysql_warning_count(hdl)) {
              w = php_get_warnings(hdl TSRMLS_CC);
       } else {
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "No warnings found");
              RETURN_FALSE;
       }

       mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
       mysqli_resource->ptr = mysqli_resource->info = (void *)w;
       mysqli_resource->status = MYSQLI_STATUS_VALID;

       if (!getThis() || !instanceof_function(Z_OBJCE_P(getThis()), mysqli_warning_class_entry TSRMLS_CC)) {
              MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_warning_class_entry);
       } else {
              ((mysqli_object *) zend_object_store_get_object(getThis() TSRMLS_CC))->ptr = mysqli_resource;
       }

}

Here is the call graph for this function:

static MYSQLI_WARNING* php_new_warning ( const char *  reason,
int errorno  TSRMLS_DC 
) [static]

Definition at line 58 of file mysqli_warning.c.

{
       MYSQLI_WARNING *w;

       w = (MYSQLI_WARNING *)ecalloc(1, sizeof(MYSQLI_WARNING));

       ZVAL_UTF8_STRING(&(w->reason), reason, ZSTR_DUPLICATE);

       ZVAL_UTF8_STRINGL(&(w->sqlstate), "HY000", sizeof("HY000") - 1,  ZSTR_DUPLICATE);

       w->errorno = errorno;

       return w;
}

Here is the caller graph for this function:


Variable Documentation

Initial value:
 {

       PHP_ME(mysqli_warning, next,                     NULL, ZEND_ACC_PUBLIC)
       {NULL, NULL, NULL}
}

Definition at line 316 of file mysqli_warning.c.

Initial value:
 {
       {"message", sizeof("message") - 1, mysqli_warning_message, NULL},
       {"sqlstate", sizeof("sqlstate") - 1, mysqli_warning_sqlstate, NULL},
       {"errno", sizeof("errno") - 1, mysqli_warning_errno, NULL},
       {NULL, 0, NULL, NULL}
}

Definition at line 324 of file mysqli_warning.c.

Initial value:
 {
       {ZEND_ACC_PUBLIC, "message",       sizeof("message") - 1,      0, NULL, 0, NULL},
       {ZEND_ACC_PUBLIC, "sqlstate",      sizeof("sqlstate") - 1,     0, NULL, 0, NULL},
       {ZEND_ACC_PUBLIC, "errno",         sizeof("errno") - 1,        0, NULL, 0, NULL},
       {0,                                NULL,                0,                                 0, NULL, 0, NULL}
}

Definition at line 333 of file mysqli_warning.c.