Back to index

php5  5.3.10
Defines | Functions | Variables
mysqli_prop.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 CHECK_STATUS(value)
#define MYSQLI_GET_MYSQL(statusval)
#define MYSQLI_GET_RESULT(statusval)
#define MYSQLI_GET_STMT(statusval)
#define MYSQLI_MAP_PROPERTY_FUNC_LONG(__func, __int_func, __get_type, __ret_type, __ret_type_sprint_mod)
#define MYSQLI_MAP_PROPERTY_FUNC_STRING(__func, __int_func, __get_type)

Functions

static int link_client_version_read (mysqli_object *obj, zval **retval TSRMLS_DC)
static int link_client_info_read (mysqli_object *obj, zval **retval TSRMLS_DC)
static int link_connect_errno_read (mysqli_object *obj, zval **retval TSRMLS_DC)
static int link_connect_error_read (mysqli_object *obj, zval **retval TSRMLS_DC)
static int link_affected_rows_read (mysqli_object *obj, zval **retval TSRMLS_DC)
static int link_stat_read (mysqli_object *obj, zval **retval TSRMLS_DC)
static int result_type_read (mysqli_object *obj, zval **retval TSRMLS_DC)
static int result_lengths_read (mysqli_object *obj, zval **retval TSRMLS_DC)
static int stmt_id_read (mysqli_object *obj, zval **retval TSRMLS_DC)
static int stmt_affected_rows_read (mysqli_object *obj, zval **retval TSRMLS_DC)

Variables

const mysqli_property_entry mysqli_link_property_entries []
zend_property_info mysqli_link_property_info_entries []
const mysqli_property_entry mysqli_result_property_entries []
zend_property_info mysqli_result_property_info_entries []
const mysqli_property_entry mysqli_stmt_property_entries []
zend_property_info mysqli_stmt_property_info_entries []

Define Documentation

#define CHECK_STATUS (   value)
Value:
if (!obj->ptr || ((MYSQLI_RESOURCE *)obj->ptr)->status < value ) { \
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "Property access is not allowed yet"); \
              ZVAL_NULL(*retval); \
              return SUCCESS; \
       } \

Definition at line 33 of file mysqli_prop.c.

#define MYSQLI_GET_MYSQL (   statusval)
Value:
MYSQL *p; \
MAKE_STD_ZVAL(*retval);\
if (!obj->ptr || !(MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr) { \
       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't fetch %s", obj->zo.ce->name);\
       ZVAL_NULL(*retval);\
       return SUCCESS; \
} else { \
       CHECK_STATUS(statusval);\
    p = (MYSQL *)((MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr)->mysql;\
}

Definition at line 40 of file mysqli_prop.c.

#define MYSQLI_GET_RESULT (   statusval)
Value:
MYSQL_RES *p; \
MAKE_STD_ZVAL(*retval);\
if (!obj->ptr) { \
       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't fetch %s", obj->zo.ce->name);\
       ZVAL_NULL(*retval);\
       return SUCCESS; \
} else { \
       CHECK_STATUS(statusval);\
       p = (MYSQL_RES *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr; \
}

Definition at line 52 of file mysqli_prop.c.

#define MYSQLI_GET_STMT (   statusval)
Value:
MYSQL_STMT *p; \
MAKE_STD_ZVAL(*retval);\
if (!obj->ptr) { \
       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't fetch %s", obj->zo.ce->name);\
       ZVAL_NULL(*retval);\
       return SUCCESS; \
} else { \
       CHECK_STATUS(statusval);\
       p = (MYSQL_STMT *)((MY_STMT *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr)->stmt;\
}

Definition at line 65 of file mysqli_prop.c.

#define MYSQLI_MAP_PROPERTY_FUNC_LONG (   __func,
  __int_func,
  __get_type,
  __ret_type,
  __ret_type_sprint_mod 
)
Value:
static int __func(mysqli_object *obj, zval **retval TSRMLS_DC) \
{\
       __ret_type l;\
       __get_type;\
       if (!p) {\
              ZVAL_NULL(*retval);\
       } else {\
              l = (__ret_type)__int_func(p);\
              if (l < LONG_MAX) {\
                     ZVAL_LONG(*retval, (long) l);\
              } else { \
                     char *ret; \
                     int ret_len = spprintf(&ret, 0, __ret_type_sprint_mod, l); \
                     ZVAL_STRINGL(*retval, ret, ret_len, 0); \
              } \
       }\
       return SUCCESS;\
}

Definition at line 77 of file mysqli_prop.c.

#define MYSQLI_MAP_PROPERTY_FUNC_STRING (   __func,
  __int_func,
  __get_type 
)
Value:
static int __func(mysqli_object *obj, zval **retval TSRMLS_DC)\
{\
       char *c;\
       __get_type;\
       if (!p) {\
              ZVAL_NULL(*retval);\
       } else {\
              c = (char *)__int_func(p);\
              if (!c) {\
                     ZVAL_NULL(*retval);\
              } else {\
                     ZVAL_STRING(*retval, c, 1);\
              }\
       }\
       return SUCCESS;\
}

Definition at line 97 of file mysqli_prop.c.


Function Documentation

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

Definition at line 157 of file mysqli_prop.c.

{
       MY_MYSQL *mysql;
       my_ulonglong rc;

       MAKE_STD_ZVAL(*retval);

       CHECK_STATUS(MYSQLI_STATUS_INITIALIZED);

       mysql = (MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;

       if (!mysql) {
              ZVAL_NULL(*retval);
       } else {
              CHECK_STATUS(MYSQLI_STATUS_VALID);

              rc = mysql_affected_rows(mysql->mysql);

              if (rc == (my_ulonglong) -1) {
                     ZVAL_LONG(*retval, -1);
                     return SUCCESS;
              }

              if (rc < LONG_MAX) {
                     ZVAL_LONG(*retval, (long) rc);
              } else {
                     char *ret;
                     int l = spprintf(&ret, 0, MYSQLI_LLU_SPEC, rc);
                     ZVAL_STRINGL(*retval, ret, l, 0);
              }
       }
       return SUCCESS;
}

Here is the call graph for this function:

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

Definition at line 125 of file mysqli_prop.c.

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

Definition at line 116 of file mysqli_prop.c.

{
       MAKE_STD_ZVAL(*retval);
       ZVAL_LONG(*retval, MYSQL_VERSION_ID);
       return SUCCESS;
}
static int link_connect_errno_read ( mysqli_object obj,
zval **retval  TSRMLS_DC 
) [static]

Definition at line 135 of file mysqli_prop.c.

{
       MAKE_STD_ZVAL(*retval);
       ZVAL_LONG(*retval, (long)MyG(error_no));
       return SUCCESS;
}
static int link_connect_error_read ( mysqli_object obj,
zval **retval  TSRMLS_DC 
) [static]

Definition at line 144 of file mysqli_prop.c.

{
       MAKE_STD_ZVAL(*retval);
       if (MyG(error_msg)) {
              ZVAL_STRING(*retval, MyG(error_msg), 1);
       } else {
              ZVAL_NULL(*retval);
       }
       return SUCCESS;
}
static int link_stat_read ( mysqli_object obj,
zval **retval  TSRMLS_DC 
) [static]

Definition at line 207 of file mysqli_prop.c.

{\
	MY_MYSQL *mysql;

       MAKE_STD_ZVAL(*retval);
       ZVAL_NULL(*retval);

       CHECK_STATUS(MYSQLI_STATUS_INITIALIZED);

       mysql = (MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;

       if (mysql) {
              char * stat_msg;
#if defined(MYSQLI_USE_MYSQLND)
              uint stat_msg_len;
              if (mysqlnd_stat(mysql->mysql, &stat_msg, &stat_msg_len) == PASS) {
                     ZVAL_STRINGL(*retval, stat_msg, stat_msg_len, 0);
              }
#else
              if ((stat_msg = (char *) mysql_stat(mysql->mysql))) {
                     ZVAL_STRING(*retval, stat_msg, 1);
              }
#endif
       }
       return SUCCESS;
}
static int result_lengths_read ( mysqli_object obj,
zval **retval  TSRMLS_DC 
) [static]

Definition at line 256 of file mysqli_prop.c.

{
       MYSQL_RES *p;
       ulong *ret;

       MAKE_STD_ZVAL(*retval);

       CHECK_STATUS(MYSQLI_STATUS_VALID);
       p = (MYSQL_RES *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
       if (!p || !p->field_count || !(ret = mysql_fetch_lengths(p))) {
              ZVAL_NULL(*retval);
       } else {
              ulong i;

              array_init(*retval);

              for (i = 0; i < p->field_count; i++) {
                     add_index_long(*retval, i, ret[i]);
              }
       }
       return SUCCESS;
}

Here is the call graph for this function:

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

Definition at line 238 of file mysqli_prop.c.

{
       MYSQL_RES *p;

       MAKE_STD_ZVAL(*retval);
       CHECK_STATUS(MYSQLI_STATUS_VALID);
       p = (MYSQL_RES *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;

       if (!p) {
              ZVAL_NULL(*retval);
       } else {
              ZVAL_LONG(*retval, mysqli_result_is_unbuffered(p) ? MYSQLI_USE_RESULT:MYSQLI_STORE_RESULT);
       }
       return SUCCESS;
}
static int stmt_affected_rows_read ( mysqli_object obj,
zval **retval  TSRMLS_DC 
) [static]

Definition at line 307 of file mysqli_prop.c.

{
       MY_STMT *p;
       my_ulonglong rc;

       MAKE_STD_ZVAL(*retval);
       CHECK_STATUS(MYSQLI_STATUS_VALID);

       p = (MY_STMT *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;

       if (!p) {
              ZVAL_NULL(*retval);
       } else {
              rc = mysql_stmt_affected_rows(p->stmt);

              if (rc == (my_ulonglong) -1) {
                     ZVAL_LONG(*retval, -1);
                     return SUCCESS;
              }

              if (rc < LONG_MAX) {
                     ZVAL_LONG(*retval, (long) rc);
              } else {
                     char *ret;
                     int l = spprintf(&ret, 0, MYSQLI_LLU_SPEC, rc);
                     ZVAL_STRINGL(*retval, ret, l, 0);
              }
       }
       return SUCCESS;
}

Here is the call graph for this function:

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

Definition at line 288 of file mysqli_prop.c.

{
       MY_STMT *p;

       MAKE_STD_ZVAL(*retval);
       CHECK_STATUS(MYSQLI_STATUS_VALID);

       p = (MY_STMT*)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;

       if (!p) {
              ZVAL_NULL(*retval);
       } else {
              ZVAL_LONG(*retval, mysqli_stmt_get_id(p->stmt));
       }
       return SUCCESS;
}

Variable Documentation

Initial value:
 {
       {"affected_rows",    sizeof("affected_rows") - 1,       link_affected_rows_read, NULL},
       {"client_info",      sizeof("client_info") - 1,         link_client_info_read, NULL},
       {"client_version",   sizeof("client_version") - 1,      link_client_version_read, NULL},
       {"connect_errno",    sizeof("connect_errno") - 1,       link_connect_errno_read, NULL},
       {"connect_error",    sizeof("connect_error") - 1,       link_connect_error_read, NULL},
       {"errno",                   sizeof("errno") - 1,               link_errno_read, NULL},
       {"error",                   sizeof("error") - 1,               link_error_read, NULL},
       {"field_count",             sizeof("field_count") - 1,         link_field_count_read, NULL},
       {"host_info",        sizeof("host_info") - 1,           link_host_info_read, NULL},
       {"info",                    sizeof("info") - 1,                       link_info_read, NULL},
       {"insert_id",        sizeof("insert_id") - 1,           link_insert_id_read, NULL},
       {"server_info",             sizeof("server_info") - 1,         link_server_info_read, NULL},
       {"server_version",   sizeof("server_version") - 1,      link_server_version_read, NULL},
       {"stat",                    sizeof("stat") - 1,                       link_stat_read, NULL},
       {"sqlstate",         sizeof("sqlstate") - 1,                   link_sqlstate_read, NULL},
       {"protocol_version",sizeof("protocol_version") - 1,     link_protocol_version_read, NULL},
       {"thread_id",        sizeof("thread_id") - 1,           link_thread_id_read, NULL},
       {"warning_count",    sizeof("warning_count") - 1,       link_warning_count_read, NULL},
       {NULL, 0, NULL, NULL}
}

Definition at line 348 of file mysqli_prop.c.

Initial value:
 {
       {ZEND_ACC_PUBLIC, "affected_rows", sizeof("affected_rows") - 1,       0, NULL, 0, NULL},
       {ZEND_ACC_PUBLIC, "client_info",   sizeof("client_info") - 1,         0, NULL, 0, NULL},
       {ZEND_ACC_PUBLIC, "client_version",       sizeof("client_version") - 1,      0, NULL, 0, NULL},
       {ZEND_ACC_PUBLIC, "connect_errno", sizeof("connect_errno") - 1,       0, NULL, 0, NULL},
       {ZEND_ACC_PUBLIC, "connect_error", sizeof("connect_error") - 1,       0, NULL, 0, NULL},
       {ZEND_ACC_PUBLIC, "errno",                sizeof("errno") - 1,               0, NULL, 0, NULL},
       {ZEND_ACC_PUBLIC, "error",                sizeof("error") - 1,               0, NULL, 0, NULL},
       {ZEND_ACC_PUBLIC, "field_count",   sizeof("field_count") - 1,         0, NULL, 0, NULL},
       {ZEND_ACC_PUBLIC, "host_info",            sizeof("host_info") - 1,           0, NULL, 0, NULL},
       {ZEND_ACC_PUBLIC, "info",                 sizeof("info") - 1,                       0, NULL, 0, NULL},
       {ZEND_ACC_PUBLIC, "insert_id",            sizeof("insert_id") - 1,           0, NULL, 0, NULL},
       {ZEND_ACC_PUBLIC, "server_info",   sizeof("server_info") - 1,         0, NULL, 0, NULL},
       {ZEND_ACC_PUBLIC, "server_version",       sizeof("server_version") - 1,      0, NULL, 0, NULL},
       {ZEND_ACC_PUBLIC, "stat",                 sizeof("stat") - 1,                       0, NULL, 0, NULL},
       {ZEND_ACC_PUBLIC, "sqlstate",             sizeof("sqlstate") - 1,                   0, NULL, 0, NULL},
       {ZEND_ACC_PUBLIC, "protocol_version", sizeof("protocol_version")-1, 0, NULL, 0, NULL},
       {ZEND_ACC_PUBLIC, "thread_id",            sizeof("thread_id") - 1,           0, NULL, 0, NULL},
       {ZEND_ACC_PUBLIC, "warning_count", sizeof("warning_count") - 1,       0, NULL, 0, NULL},
       {0,                                NULL,                0,                                                      0, NULL, 0, NULL}
}

Definition at line 371 of file mysqli_prop.c.

Initial value:
 {
       {"current_field",sizeof("current_field")-1,      result_current_field_read, NULL},
       {"field_count", sizeof("field_count") - 1,       result_field_count_read, NULL},
       {"lengths",   sizeof("lengths") - 1,             result_lengths_read, NULL},
       {"num_rows",  sizeof("num_rows") - 1,            result_num_rows_read, NULL},
       {"type",             sizeof("type") - 1,                result_type_read, NULL},
       {NULL, 0, NULL, NULL}
}

Definition at line 394 of file mysqli_prop.c.

Initial value:
 {
       {ZEND_ACC_PUBLIC, "current_field", sizeof("current_field")-1,  0, NULL, 0, NULL},
       {ZEND_ACC_PUBLIC, "field_count",   sizeof("field_count") - 1,  0, NULL, 0, NULL},
       {ZEND_ACC_PUBLIC, "lengths",              sizeof("lengths") - 1,             0, NULL, 0, NULL},
       {ZEND_ACC_PUBLIC, "num_rows",             sizeof("num_rows") - 1,     0, NULL, 0, NULL},
       {ZEND_ACC_PUBLIC, "type",                 sizeof("type") - 1,         0, NULL, 0, NULL},
       {0,                                NULL,                0,                                               0, NULL, 0, NULL}
}

Definition at line 403 of file mysqli_prop.c.

Initial value:
 {
       {"affected_rows", sizeof("affected_rows")-1,stmt_affected_rows_read, NULL},
       {"insert_id", sizeof("insert_id") - 1,    stmt_insert_id_read, NULL},
       {"num_rows",  sizeof("num_rows") - 1,     stmt_num_rows_read, NULL},
       {"param_count", sizeof("param_count") - 1,       stmt_param_count_read, NULL},
       {"field_count", sizeof("field_count") - 1,       stmt_field_count_read, NULL},
       {"errno",            sizeof("errno") - 1,        stmt_errno_read, NULL},
       {"error",            sizeof("error") - 1,               stmt_error_read, NULL},
       {"sqlstate",  sizeof("sqlstate") - 1,            stmt_sqlstate_read, NULL},
       {"id",               sizeof("id") - 1,                  stmt_id_read, NULL},
       {NULL, 0, NULL, NULL}
}

Definition at line 412 of file mysqli_prop.c.

Initial value:
 {
       {ZEND_ACC_PUBLIC, "affected_rows", sizeof("affected_rows") - 1,       0, NULL, 0, NULL},
       {ZEND_ACC_PUBLIC, "insert_id",     sizeof("insert_id") - 1,           0, NULL, 0, NULL},
       {ZEND_ACC_PUBLIC, "num_rows",      sizeof("num_rows") - 1,                   0, NULL, 0, NULL},
       {ZEND_ACC_PUBLIC, "param_count",sizeof("param_count") - 1,            0, NULL, 0, NULL},
       {ZEND_ACC_PUBLIC, "field_count",sizeof("field_count") - 1,            0, NULL, 0, NULL},
       {ZEND_ACC_PUBLIC, "errno",         sizeof("errno") - 1,               0, NULL, 0, NULL},
       {ZEND_ACC_PUBLIC, "error",         sizeof("error") - 1,               0, NULL, 0, NULL},
       {ZEND_ACC_PUBLIC, "sqlstate",      sizeof("sqlstate") - 1,                   0, NULL, 0, NULL},
       {ZEND_ACC_PUBLIC, "id",                   sizeof("id") - 1,                         0, NULL, 0, NULL},
       {0,                                NULL,                0,                                               0, NULL, 0, NULL}
}

Definition at line 426 of file mysqli_prop.c.