Back to index

php5  5.3.10
Defines | Functions | Variables
php_pdo_int.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define PDO_DBH_CLEAR_ERR()
#define PDO_STMT_CLEAR_ERR()   strcpy(stmt->error_code, PDO_ERR_NONE)
#define PDO_HANDLE_DBH_ERR()   if (strcmp(dbh->error_code, PDO_ERR_NONE)) { pdo_handle_error(dbh, NULL TSRMLS_CC); }
#define PDO_HANDLE_STMT_ERR()   if (strcmp(stmt->error_code, PDO_ERR_NONE)) { pdo_handle_error(stmt->dbh, stmt TSRMLS_CC); }

Functions

PDO_API zend_class_entry * php_pdo_get_exception_base (int root TSRMLS_DC)
int php_pdo_list_entry (void)
void pdo_dbh_init (TSRMLS_D)
void pdo_stmt_init (TSRMLS_D)
zend_object_value pdo_dbh_new (zend_class_entry *ce TSRMLS_DC)
 ZEND_RSRC_DTOR_FUNC (php_pdo_pdbh_dtor)
zend_object_value pdo_dbstmt_new (zend_class_entry *ce TSRMLS_DC)
void pdo_dbstmt_free_storage (pdo_stmt_t *stmt TSRMLS_DC)
zend_object_iterator * pdo_stmt_iter_get (zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC)
int pdo_stmt_describe_columns (pdo_stmt_t *stmt TSRMLS_DC)
int pdo_stmt_setup_fetch_mode (INTERNAL_FUNCTION_PARAMETERS, pdo_stmt_t *stmt, int skip_first_arg)
zend_object_value pdo_row_new (zend_class_entry *ce TSRMLS_DC)
void pdo_row_free_storage (pdo_stmt_t *stmt TSRMLS_DC)
zend_object_iterator * php_pdo_dbstmt_iter_get (zend_class_entry *ce, zval *object TSRMLS_DC)
pdo_driver_tpdo_find_driver (const char *name, int namelen)
void pdo_handle_error (pdo_dbh_t *dbh, pdo_stmt_t *stmt TSRMLS_DC)
int pdo_sqlstate_init_error_table (void)
void pdo_sqlstate_fini_error_table (void)
const char * pdo_sqlstate_state_to_description (char *state)
int pdo_hash_methods (pdo_dbh_t *dbh, int kind TSRMLS_DC)

Variables

HashTable pdo_driver_hash
zend_class_entry * pdo_exception_ce
const zend_function_entry pdo_dbh_functions []
zend_class_entry * pdo_dbh_ce
const zend_function_entry pdo_dbstmt_functions []
zend_class_entry * pdo_dbstmt_ce
zend_object_handlers pdo_dbstmt_object_handlers
const zend_function_entry pdo_row_functions []
zend_class_entry * pdo_row_ce
zend_object_handlers pdo_row_object_handlers

Define Documentation

#define PDO_DBH_CLEAR_ERR ( )
Value:
do { \
       strncpy(dbh->error_code, PDO_ERR_NONE, sizeof(PDO_ERR_NONE)); \
       if (dbh->query_stmt) { \
              dbh->query_stmt = NULL; \
              zend_objects_store_del_ref(&dbh->query_stmt_zval TSRMLS_CC); \
       } \
} while (0)

Definition at line 60 of file php_pdo_int.h.

#define PDO_HANDLE_DBH_ERR ( )    if (strcmp(dbh->error_code, PDO_ERR_NONE)) { pdo_handle_error(dbh, NULL TSRMLS_CC); }

Definition at line 68 of file php_pdo_int.h.

#define PDO_HANDLE_STMT_ERR ( )    if (strcmp(stmt->error_code, PDO_ERR_NONE)) { pdo_handle_error(stmt->dbh, stmt TSRMLS_CC); }

Definition at line 69 of file php_pdo_int.h.

#define PDO_STMT_CLEAR_ERR ( )    strcpy(stmt->error_code, PDO_ERR_NONE)

Definition at line 67 of file php_pdo_int.h.


Function Documentation

void pdo_dbh_init ( TSRMLS_D  )

Definition at line 1389 of file pdo_dbh.c.

{
       zend_class_entry ce;

       INIT_CLASS_ENTRY(ce, "PDO", pdo_dbh_functions);
       pdo_dbh_ce = zend_register_internal_class(&ce TSRMLS_CC);
       pdo_dbh_ce->create_object = pdo_dbh_new;

       memcpy(&pdo_dbh_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
       pdo_dbh_object_handlers.get_method = dbh_method_get;
       pdo_dbh_object_handlers.compare_objects = dbh_compare;
       
       REGISTER_PDO_CLASS_CONST_LONG("PARAM_BOOL", (long)PDO_PARAM_BOOL);
       REGISTER_PDO_CLASS_CONST_LONG("PARAM_NULL", (long)PDO_PARAM_NULL);
       REGISTER_PDO_CLASS_CONST_LONG("PARAM_INT",  (long)PDO_PARAM_INT);
       REGISTER_PDO_CLASS_CONST_LONG("PARAM_STR",  (long)PDO_PARAM_STR);
       REGISTER_PDO_CLASS_CONST_LONG("PARAM_LOB",  (long)PDO_PARAM_LOB);
       REGISTER_PDO_CLASS_CONST_LONG("PARAM_STMT", (long)PDO_PARAM_STMT);
       REGISTER_PDO_CLASS_CONST_LONG("PARAM_INPUT_OUTPUT", (long)PDO_PARAM_INPUT_OUTPUT);

       REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_ALLOC",        (long)PDO_PARAM_EVT_ALLOC);
       REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_FREE",                (long)PDO_PARAM_EVT_FREE);
       REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_EXEC_PRE",            (long)PDO_PARAM_EVT_EXEC_PRE);
       REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_EXEC_POST",    (long)PDO_PARAM_EVT_EXEC_POST);
       REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_FETCH_PRE",    (long)PDO_PARAM_EVT_FETCH_PRE);
       REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_FETCH_POST",   (long)PDO_PARAM_EVT_FETCH_POST);
       REGISTER_PDO_CLASS_CONST_LONG("PARAM_EVT_NORMALIZE",    (long)PDO_PARAM_EVT_NORMALIZE);

       REGISTER_PDO_CLASS_CONST_LONG("FETCH_LAZY", (long)PDO_FETCH_LAZY);
       REGISTER_PDO_CLASS_CONST_LONG("FETCH_ASSOC",(long)PDO_FETCH_ASSOC);
       REGISTER_PDO_CLASS_CONST_LONG("FETCH_NUM",  (long)PDO_FETCH_NUM);
       REGISTER_PDO_CLASS_CONST_LONG("FETCH_BOTH", (long)PDO_FETCH_BOTH);
       REGISTER_PDO_CLASS_CONST_LONG("FETCH_OBJ",  (long)PDO_FETCH_OBJ);
       REGISTER_PDO_CLASS_CONST_LONG("FETCH_BOUND",(long)PDO_FETCH_BOUND);
       REGISTER_PDO_CLASS_CONST_LONG("FETCH_COLUMN",(long)PDO_FETCH_COLUMN);
       REGISTER_PDO_CLASS_CONST_LONG("FETCH_CLASS",(long)PDO_FETCH_CLASS);
       REGISTER_PDO_CLASS_CONST_LONG("FETCH_INTO", (long)PDO_FETCH_INTO);
       REGISTER_PDO_CLASS_CONST_LONG("FETCH_FUNC", (long)PDO_FETCH_FUNC);
       REGISTER_PDO_CLASS_CONST_LONG("FETCH_GROUP",(long)PDO_FETCH_GROUP);
       REGISTER_PDO_CLASS_CONST_LONG("FETCH_UNIQUE",(long)PDO_FETCH_UNIQUE);
       REGISTER_PDO_CLASS_CONST_LONG("FETCH_KEY_PAIR",(long)PDO_FETCH_KEY_PAIR);
       REGISTER_PDO_CLASS_CONST_LONG("FETCH_CLASSTYPE",(long)PDO_FETCH_CLASSTYPE);
#if PHP_MAJOR_VERSION > 5 || PHP_MINOR_VERSION >= 1
       REGISTER_PDO_CLASS_CONST_LONG("FETCH_SERIALIZE",(long)PDO_FETCH_SERIALIZE);
#endif
       REGISTER_PDO_CLASS_CONST_LONG("FETCH_PROPS_LATE",(long)PDO_FETCH_PROPS_LATE);
       REGISTER_PDO_CLASS_CONST_LONG("FETCH_NAMED",(long)PDO_FETCH_NAMED);

       REGISTER_PDO_CLASS_CONST_LONG("ATTR_AUTOCOMMIT", (long)PDO_ATTR_AUTOCOMMIT);
       REGISTER_PDO_CLASS_CONST_LONG("ATTR_PREFETCH",          (long)PDO_ATTR_PREFETCH);
       REGISTER_PDO_CLASS_CONST_LONG("ATTR_TIMEOUT",           (long)PDO_ATTR_TIMEOUT);
       REGISTER_PDO_CLASS_CONST_LONG("ATTR_ERRMODE",           (long)PDO_ATTR_ERRMODE);
       REGISTER_PDO_CLASS_CONST_LONG("ATTR_SERVER_VERSION",    (long)PDO_ATTR_SERVER_VERSION);
       REGISTER_PDO_CLASS_CONST_LONG("ATTR_CLIENT_VERSION",    (long)PDO_ATTR_CLIENT_VERSION);
       REGISTER_PDO_CLASS_CONST_LONG("ATTR_SERVER_INFO",              (long)PDO_ATTR_SERVER_INFO);
       REGISTER_PDO_CLASS_CONST_LONG("ATTR_CONNECTION_STATUS",        (long)PDO_ATTR_CONNECTION_STATUS);
       REGISTER_PDO_CLASS_CONST_LONG("ATTR_CASE",                     (long)PDO_ATTR_CASE);
       REGISTER_PDO_CLASS_CONST_LONG("ATTR_CURSOR_NAME",       (long)PDO_ATTR_CURSOR_NAME);
       REGISTER_PDO_CLASS_CONST_LONG("ATTR_CURSOR",            (long)PDO_ATTR_CURSOR);
       REGISTER_PDO_CLASS_CONST_LONG("ATTR_ORACLE_NULLS",      (long)PDO_ATTR_ORACLE_NULLS);
       REGISTER_PDO_CLASS_CONST_LONG("ATTR_PERSISTENT", (long)PDO_ATTR_PERSISTENT);
       REGISTER_PDO_CLASS_CONST_LONG("ATTR_STATEMENT_CLASS",          (long)PDO_ATTR_STATEMENT_CLASS);
       REGISTER_PDO_CLASS_CONST_LONG("ATTR_FETCH_TABLE_NAMES",        (long)PDO_ATTR_FETCH_TABLE_NAMES);
       REGISTER_PDO_CLASS_CONST_LONG("ATTR_FETCH_CATALOG_NAMES",             (long)PDO_ATTR_FETCH_CATALOG_NAMES);
       REGISTER_PDO_CLASS_CONST_LONG("ATTR_DRIVER_NAME",              (long)PDO_ATTR_DRIVER_NAME);
       REGISTER_PDO_CLASS_CONST_LONG("ATTR_STRINGIFY_FETCHES",(long)PDO_ATTR_STRINGIFY_FETCHES);
       REGISTER_PDO_CLASS_CONST_LONG("ATTR_MAX_COLUMN_LEN",(long)PDO_ATTR_MAX_COLUMN_LEN);
       REGISTER_PDO_CLASS_CONST_LONG("ATTR_EMULATE_PREPARES",(long)PDO_ATTR_EMULATE_PREPARES);
       REGISTER_PDO_CLASS_CONST_LONG("ATTR_DEFAULT_FETCH_MODE",(long)PDO_ATTR_DEFAULT_FETCH_MODE);
       
       REGISTER_PDO_CLASS_CONST_LONG("ERRMODE_SILENT",  (long)PDO_ERRMODE_SILENT);
       REGISTER_PDO_CLASS_CONST_LONG("ERRMODE_WARNING", (long)PDO_ERRMODE_WARNING);
       REGISTER_PDO_CLASS_CONST_LONG("ERRMODE_EXCEPTION",      (long)PDO_ERRMODE_EXCEPTION);

       REGISTER_PDO_CLASS_CONST_LONG("CASE_NATURAL",    (long)PDO_CASE_NATURAL);
       REGISTER_PDO_CLASS_CONST_LONG("CASE_LOWER",      (long)PDO_CASE_LOWER);
       REGISTER_PDO_CLASS_CONST_LONG("CASE_UPPER",      (long)PDO_CASE_UPPER);

       REGISTER_PDO_CLASS_CONST_LONG("NULL_NATURAL",    (long)PDO_NULL_NATURAL);
       REGISTER_PDO_CLASS_CONST_LONG("NULL_EMPTY_STRING",      (long)PDO_NULL_EMPTY_STRING);
       REGISTER_PDO_CLASS_CONST_LONG("NULL_TO_STRING",  (long)PDO_NULL_TO_STRING);
                     
       REGISTER_PDO_CLASS_CONST_STRING("ERR_NONE",      PDO_ERR_NONE);

       REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_NEXT", (long)PDO_FETCH_ORI_NEXT);
       REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_PRIOR", (long)PDO_FETCH_ORI_PRIOR);
       REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_FIRST", (long)PDO_FETCH_ORI_FIRST);
       REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_LAST", (long)PDO_FETCH_ORI_LAST);
       REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_ABS", (long)PDO_FETCH_ORI_ABS);
       REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_REL", (long)PDO_FETCH_ORI_REL);
       
       REGISTER_PDO_CLASS_CONST_LONG("CURSOR_FWDONLY", (long)PDO_CURSOR_FWDONLY);
       REGISTER_PDO_CLASS_CONST_LONG("CURSOR_SCROLL", (long)PDO_CURSOR_SCROLL);

#if 0
       REGISTER_PDO_CLASS_CONST_LONG("ERR_CANT_MAP",           (long)PDO_ERR_CANT_MAP);
       REGISTER_PDO_CLASS_CONST_LONG("ERR_SYNTAX",             (long)PDO_ERR_SYNTAX);
       REGISTER_PDO_CLASS_CONST_LONG("ERR_CONSTRAINT",  (long)PDO_ERR_CONSTRAINT);
       REGISTER_PDO_CLASS_CONST_LONG("ERR_NOT_FOUND",          (long)PDO_ERR_NOT_FOUND);
       REGISTER_PDO_CLASS_CONST_LONG("ERR_ALREADY_EXISTS",     (long)PDO_ERR_ALREADY_EXISTS);
       REGISTER_PDO_CLASS_CONST_LONG("ERR_NOT_IMPLEMENTED",    (long)PDO_ERR_NOT_IMPLEMENTED);
       REGISTER_PDO_CLASS_CONST_LONG("ERR_MISMATCH",           (long)PDO_ERR_MISMATCH);
       REGISTER_PDO_CLASS_CONST_LONG("ERR_TRUNCATED",          (long)PDO_ERR_TRUNCATED);
       REGISTER_PDO_CLASS_CONST_LONG("ERR_DISCONNECTED",       (long)PDO_ERR_DISCONNECTED);
       REGISTER_PDO_CLASS_CONST_LONG("ERR_NO_PERM",            (long)PDO_ERR_NO_PERM);
#endif

}

Here is the call graph for this function:

Here is the caller graph for this function:

zend_object_value pdo_dbh_new ( zend_class_entry *ce  TSRMLS_DC)

Definition at line 1571 of file pdo_dbh.c.

{
       zend_object_value retval;
       pdo_dbh_t *dbh;
       zval *tmp;

       dbh = emalloc(sizeof(*dbh));
       memset(dbh, 0, sizeof(*dbh));
       dbh->ce = ce;
       dbh->refcount = 1;
       ALLOC_HASHTABLE(dbh->properties);
       zend_hash_init(dbh->properties, 0, NULL, ZVAL_PTR_DTOR, 0);
       zend_hash_copy(dbh->properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
       dbh->def_stmt_ce = pdo_dbstmt_ce;
       
       retval.handle = zend_objects_store_put(dbh, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t)pdo_dbh_free_storage, NULL TSRMLS_CC);
       retval.handlers = &pdo_dbh_object_handlers;
       
       return retval;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pdo_dbstmt_free_storage ( pdo_stmt_t *stmt  TSRMLS_DC)

Definition at line 2452 of file pdo_stmt.c.

Here is the call graph for this function:

Here is the caller graph for this function:

zend_object_value pdo_dbstmt_new ( zend_class_entry *ce  TSRMLS_DC)

Definition at line 2457 of file pdo_stmt.c.

{
       zend_object_value retval;
       zval *tmp;

       pdo_stmt_t *stmt;
       stmt = emalloc(sizeof(*stmt));
       memset(stmt, 0, sizeof(*stmt));
       stmt->ce = ce;
       stmt->refcount = 1;
       ALLOC_HASHTABLE(stmt->properties);
       zend_hash_init(stmt->properties, 0, NULL, ZVAL_PTR_DTOR, 0);
       zend_hash_copy(stmt->properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));

       retval.handle = zend_objects_store_put(stmt, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t)pdo_dbstmt_free_storage, (zend_objects_store_clone_t)dbstmt_clone_obj TSRMLS_CC);
       retval.handlers = &pdo_dbstmt_object_handlers;

       return retval;
}

Here is the call graph for this function:

Here is the caller graph for this function:

pdo_driver_t* pdo_find_driver ( const char *  name,
int  namelen 
)

Definition at line 206 of file pdo.c.

{
       pdo_driver_t **driver = NULL;
       
       zend_hash_find(&pdo_driver_hash, (char*)name, namelen, (void**)&driver);

       return driver ? *driver : NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pdo_handle_error ( pdo_dbh_t *  dbh,
pdo_stmt_t *stmt  TSRMLS_DC 
)

Definition at line 104 of file pdo_dbh.c.

{
       pdo_error_type *pdo_err = &dbh->error_code;
       const char *msg = "<<Unknown>>";
       char *supp = NULL;
       long native_code = 0;
       char *message = NULL;
       zval *info = NULL;

       if (dbh == NULL || dbh->error_mode == PDO_ERRMODE_SILENT) {
              return;
       }
       
       if (stmt) {
              pdo_err = &stmt->error_code;
       }

       /* hash sqlstate to error messages */
       msg = pdo_sqlstate_state_to_description(*pdo_err);
       if (!msg) {
              msg = "<<Unknown error>>";
       }

       if (dbh->methods->fetch_err) {
              MAKE_STD_ZVAL(info);
              array_init(info);

              add_next_index_string(info, *pdo_err, 1);
              
              if (dbh->methods->fetch_err(dbh, stmt, info TSRMLS_CC)) {
                     zval **item;

                     if (SUCCESS == zend_hash_index_find(Z_ARRVAL_P(info), 1, (void**)&item)) {
                            native_code = Z_LVAL_PP(item);
                     }
                     
                     if (SUCCESS == zend_hash_index_find(Z_ARRVAL_P(info), 2, (void**)&item)) {
                            supp = estrndup(Z_STRVAL_PP(item), Z_STRLEN_PP(item));
                     }
              }
       }

       if (supp) {
              spprintf(&message, 0, "SQLSTATE[%s]: %s: %ld %s", *pdo_err, msg, native_code, supp);
       } else {
              spprintf(&message, 0, "SQLSTATE[%s]: %s", *pdo_err, msg);
       }

       if (dbh->error_mode == PDO_ERRMODE_WARNING) {
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", message);
       } else if (EG(exception) == NULL) {
              zval *ex;
              zend_class_entry *def_ex = php_pdo_get_exception_base(1 TSRMLS_CC), *pdo_ex = php_pdo_get_exception();

              MAKE_STD_ZVAL(ex);
              object_init_ex(ex, pdo_ex);

              zend_update_property_string(def_ex, ex, "message", sizeof("message")-1, message TSRMLS_CC);
              zend_update_property_string(def_ex, ex, "code", sizeof("code")-1, *pdo_err TSRMLS_CC);
              
              if (info) {
                     zend_update_property(pdo_ex, ex, "errorInfo", sizeof("errorInfo")-1, info TSRMLS_CC);
              }

              zend_throw_exception_object(ex TSRMLS_CC);
       }

       if (info) {
              zval_ptr_dtor(&info);
       }

       if (message) {
              efree(message);
       }

       if (supp) {
              efree(supp);
       }
}

Here is the call graph for this function:

int pdo_hash_methods ( pdo_dbh_t *  dbh,
int kind  TSRMLS_DC 
)

Definition at line 1280 of file pdo_dbh.c.

{
       const zend_function_entry *funcs;
       zend_function func;
       zend_internal_function *ifunc = (zend_internal_function*)&func;
       int namelen;
       char *lc_name;

       if (!dbh || !dbh->methods || !dbh->methods->get_driver_methods) {
              return 0;
       }
       funcs =       dbh->methods->get_driver_methods(dbh, kind TSRMLS_CC);
       if (!funcs) {
              return 0;
       }

       if (!(dbh->cls_methods[kind] = pemalloc(sizeof(HashTable), dbh->is_persistent))) {
              php_error_docref(NULL TSRMLS_CC, E_ERROR, "out of memory while allocating PDO methods.");
       }
       zend_hash_init_ex(dbh->cls_methods[kind], 8, NULL, NULL, dbh->is_persistent, 0);

       while (funcs->fname) {
              ifunc->type = ZEND_INTERNAL_FUNCTION;
              ifunc->handler = funcs->handler;
              ifunc->function_name = (char*)funcs->fname;
              ifunc->scope = dbh->ce;
              ifunc->prototype = NULL;
              if (funcs->arg_info) {
                     ifunc->arg_info = (zend_arg_info*)funcs->arg_info + 1;
                     ifunc->num_args = funcs->num_args;
                     if (funcs->arg_info[0].required_num_args == -1) {
                            ifunc->required_num_args = funcs->num_args;
                     } else {
                            ifunc->required_num_args = funcs->arg_info[0].required_num_args;
                     }
                     ifunc->pass_rest_by_reference = funcs->arg_info[0].pass_by_reference;
                     ifunc->return_reference = funcs->arg_info[0].return_reference;
              } else {
                     ifunc->arg_info = NULL;
                     ifunc->num_args = 0;
                     ifunc->required_num_args = 0;
                     ifunc->pass_rest_by_reference = 0;
                     ifunc->return_reference = 0;
              }
              if (funcs->flags) {
                     ifunc->fn_flags = funcs->flags;
              } else {
                     ifunc->fn_flags = ZEND_ACC_PUBLIC;
              }
              namelen = strlen(funcs->fname);
              lc_name = emalloc(namelen+1);
              zend_str_tolower_copy(lc_name, funcs->fname, namelen);
              zend_hash_add(dbh->cls_methods[kind], lc_name, namelen+1, &func, sizeof(func), NULL);
              efree(lc_name);
              funcs++;
       }

       return 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pdo_row_free_storage ( pdo_stmt_t *stmt  TSRMLS_DC)

Definition at line 2782 of file pdo_stmt.c.

{
       if (stmt) {
              ZVAL_NULL(&stmt->lazy_object_ref);
              
              if (--stmt->refcount == 0) {
                     free_statement(stmt TSRMLS_CC);
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

zend_object_value pdo_row_new ( zend_class_entry *ce  TSRMLS_DC)

Definition at line 2793 of file pdo_stmt.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 307 of file pdo_sqlstate.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 312 of file pdo_sqlstate.c.

{
       int i;
       const struct pdo_sqlstate_info *info;

       if (FAILURE == zend_hash_init(&err_hash,
                     sizeof(err_initializer)/sizeof(err_initializer[0]), NULL, NULL, 1)) {
              return FAILURE;
       }

       for (i = 0; i < sizeof(err_initializer)/sizeof(err_initializer[0]); i++) {
              info = &err_initializer[i];

              zend_hash_add(&err_hash, info->state, sizeof(info->state), &info, sizeof(info), NULL);
       }

       return SUCCESS;
}

Here is the caller graph for this function:

const char* pdo_sqlstate_state_to_description ( char *  state)

Definition at line 331 of file pdo_sqlstate.c.

{
       const struct pdo_sqlstate_info **info;
       if (SUCCESS == zend_hash_find(&err_hash, state, sizeof(err_initializer[0].state),
                     (void**)&info)) {
              return (*info)->desc;
       }
       return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int pdo_stmt_describe_columns ( pdo_stmt_t *stmt  TSRMLS_DC)

Definition at line 205 of file pdo_stmt.c.

{
       int col;

       stmt->columns = ecalloc(stmt->column_count, sizeof(struct pdo_column_data));

       for (col = 0; col < stmt->column_count; col++) {
              if (!stmt->methods->describer(stmt, col TSRMLS_CC)) {
                     return 0;
              }

              /* if we are applying case conversions on column names, do so now */
              if (stmt->dbh->native_case != stmt->dbh->desired_case && stmt->dbh->desired_case != PDO_CASE_NATURAL) {
                     char *s = stmt->columns[col].name;

                     switch (stmt->dbh->desired_case) {
                            case PDO_CASE_UPPER:
                                   while (*s != '\0') {
                                          *s = toupper(*s);
                                          s++;
                                   }
                                   break;
                            case PDO_CASE_LOWER:
                                   while (*s != '\0') {
                                          *s = tolower(*s);
                                          s++;
                                   }
                                   break;
                            default:
                                   ;
                     }
              }

#if 0
              /* update the column index on named bound parameters */
              if (stmt->bound_params) {
                     struct pdo_bound_param_data *param;

                     if (SUCCESS == zend_hash_find(stmt->bound_params, stmt->columns[col].name,
                                          stmt->columns[col].namelen, (void**)&param)) {
                            param->paramno = col;
                     }
              }
#endif
              if (stmt->bound_columns) {
                     struct pdo_bound_param_data *param;

                     if (SUCCESS == zend_hash_find(stmt->bound_columns, stmt->columns[col].name,
                                          stmt->columns[col].namelen, (void**)&param)) {
                            param->paramno = col;
                     }
              }

       }
       return 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pdo_stmt_init ( TSRMLS_D  )

Definition at line 2356 of file pdo_stmt.c.

Here is the call graph for this function:

Here is the caller graph for this function:

zend_object_iterator* pdo_stmt_iter_get ( zend_class_entry *  ce,
zval *  object,
int by_ref  TSRMLS_DC 
)

Definition at line 2569 of file pdo_stmt.c.

{
       pdo_stmt_t *stmt = (pdo_stmt_t*)zend_object_store_get_object(object TSRMLS_CC);
       struct php_pdo_iterator *I;

       if (by_ref) {
              zend_error(E_ERROR, "An iterator cannot be used with foreach by reference");
       }

       I = ecalloc(1, sizeof(*I));
       I->iter.funcs = &pdo_stmt_iter_funcs;
       I->iter.data = I;
       I->stmt = stmt;
       stmt->refcount++;

       MAKE_STD_ZVAL(I->fetch_ahead);
       if (!do_fetch(I->stmt, TRUE, I->fetch_ahead, PDO_FETCH_USE_DEFAULT,
                     PDO_FETCH_ORI_NEXT, 0, 0 TSRMLS_CC)) {
              PDO_HANDLE_STMT_ERR();
              I->key = (ulong)-1;
              FREE_ZVAL(I->fetch_ahead);
              I->fetch_ahead = NULL;
       }

       return &I->iter;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int pdo_stmt_setup_fetch_mode ( INTERNAL_FUNCTION_PARAMETERS  ,
pdo_stmt_t *  stmt,
int  skip_first_arg 
)

Definition at line 1885 of file pdo_stmt.c.

{
       long mode = PDO_FETCH_BOTH;
       int flags, argc = ZEND_NUM_ARGS() - skip;
       zval ***args;
       zend_class_entry **cep;
       int retval;
       
       do_fetch_opt_finish(stmt, 1 TSRMLS_CC);

       switch (stmt->default_fetch_type) {
              case PDO_FETCH_INTO:
                     if (stmt->fetch.into) {
                            zval_ptr_dtor(&stmt->fetch.into);
                            stmt->fetch.into = NULL;
                     }
                     break;
              default:
                     ;
       }
       
       stmt->default_fetch_type = PDO_FETCH_BOTH;

       if (argc == 0) {
              return SUCCESS;
       }

       args = safe_emalloc(ZEND_NUM_ARGS(), sizeof(zval*), 0);

       retval = zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args);
       
       if (SUCCESS == retval) {
              if (Z_TYPE_PP(args[skip]) != IS_LONG) {
                     pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "mode must be an integer" TSRMLS_CC);
                     retval = FAILURE;
              } else {
                     mode = Z_LVAL_PP(args[skip]);
                     flags = mode & PDO_FETCH_FLAGS;
       
                     retval = pdo_stmt_verify_mode(stmt, mode, 0 TSRMLS_CC);
              }
       }
       
       if (FAILURE == retval) {
              PDO_STMT_CLEAR_ERR();
              efree(args);
              return FAILURE;
       }

       retval = FAILURE;
       switch (mode & ~PDO_FETCH_FLAGS) {
              case PDO_FETCH_USE_DEFAULT:
              case PDO_FETCH_LAZY:
              case PDO_FETCH_ASSOC:
              case PDO_FETCH_NUM:
              case PDO_FETCH_BOTH:
              case PDO_FETCH_OBJ:
              case PDO_FETCH_BOUND:
              case PDO_FETCH_NAMED:
              case PDO_FETCH_KEY_PAIR:
                     if (argc != 1) {
                            pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "fetch mode doesn't allow any extra arguments" TSRMLS_CC);
                     } else {
                            retval = SUCCESS;
                     }
                     break;

              case PDO_FETCH_COLUMN:
                     if (argc != 2) {
                            pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "fetch mode requires the colno argument" TSRMLS_CC);
                     } else if (Z_TYPE_PP(args[skip+1]) != IS_LONG) {
                            pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "colno must be an integer" TSRMLS_CC);
                     } else {
                            stmt->fetch.column = Z_LVAL_PP(args[skip+1]);
                            retval = SUCCESS;
                     }
                     break;

              case PDO_FETCH_CLASS:
                     /* Gets its class name from 1st column */
                     if ((flags & PDO_FETCH_CLASSTYPE) == PDO_FETCH_CLASSTYPE) {
                            if (argc != 1) {
                                   pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "fetch mode doesn't allow any extra arguments" TSRMLS_CC);
                            } else {
                                   stmt->fetch.cls.ce = NULL;
                                   retval = SUCCESS;
                            }
                     } else {
                            if (argc < 2) {
                                   pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "fetch mode requires the classname argument" TSRMLS_CC);
                            } else if (argc > 3) {
                                   pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "too many arguments" TSRMLS_CC);
                            } else if (Z_TYPE_PP(args[skip+1]) != IS_STRING) {
                                   pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "classname must be a string" TSRMLS_CC);
                            } else {
                                   retval = zend_lookup_class(Z_STRVAL_PP(args[skip+1]),
                                          Z_STRLEN_PP(args[skip+1]), &cep TSRMLS_CC);

                                   if (SUCCESS == retval && cep && *cep) {
                                          stmt->fetch.cls.ce = *cep;
                                   }
                            }
                     }

                     if (SUCCESS == retval) {
                            stmt->fetch.cls.ctor_args = NULL;
#ifdef ilia_0 /* we'll only need this when we have persistent statements, if ever */
                            if (stmt->dbh->is_persistent) {
                                   php_error_docref(NULL TSRMLS_CC, E_WARNING, "PHP might crash if you don't call $stmt->setFetchMode() to reset to defaults on this persistent statement.  This will be fixed in a later release");
                            }
#endif
                            if (argc == 3) {
                                   if (Z_TYPE_PP(args[skip+2]) != IS_NULL && Z_TYPE_PP(args[skip+2]) != IS_ARRAY) {
                                          pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "ctor_args must be either NULL or an array" TSRMLS_CC);
                                          retval = FAILURE;
                                   } else if (Z_TYPE_PP(args[skip+2]) == IS_ARRAY && zend_hash_num_elements(Z_ARRVAL_PP(args[skip+2]))) {
                                          ALLOC_ZVAL(stmt->fetch.cls.ctor_args);
                                          *stmt->fetch.cls.ctor_args = **args[skip+2];
                                          zval_copy_ctor(stmt->fetch.cls.ctor_args);
                                   }
                            }

                            if (SUCCESS == retval) {
                                   do_fetch_class_prepare(stmt TSRMLS_CC);
                            }
                     }
                     
                     break;

              case PDO_FETCH_INTO:
                     if (argc != 2) {
                            pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "fetch mode requires the object parameter" TSRMLS_CC);
                     } else if (Z_TYPE_PP(args[skip+1]) != IS_OBJECT) {
                            pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "object must be an object" TSRMLS_CC);
                     } else {
                            retval = SUCCESS;
                     }
                     
                     if (SUCCESS == retval) {
#ifdef ilia_0 /* we'll only need this when we have persistent statements, if ever */
                            if (stmt->dbh->is_persistent) {
                                   php_error_docref(NULL TSRMLS_CC, E_WARNING, "PHP might crash if you don't call $stmt->setFetchMode() to reset to defaults on this persistent statement.  This will be fixed in a later release");
                            }
#endif 
                            MAKE_STD_ZVAL(stmt->fetch.into);

                            Z_TYPE_P(stmt->fetch.into) = IS_OBJECT;
                            Z_OBJ_HANDLE_P(stmt->fetch.into) = Z_OBJ_HANDLE_PP(args[skip+1]);
                            Z_OBJ_HT_P(stmt->fetch.into) = Z_OBJ_HT_PP(args[skip+1]);
                            zend_objects_store_add_ref(stmt->fetch.into TSRMLS_CC);
                     }
                     
                     break;
              
              default:
                     pdo_raise_impl_error(stmt->dbh, stmt, "22003", "Invalid fetch mode specified" TSRMLS_CC);
       }

       if (SUCCESS == retval) {
              stmt->default_fetch_type = mode;
       }

       /*
        * PDO error (if any) has already been raised at this point.
        *
        * The error_code is cleared, otherwise the caller will read the
        * last error message from the driver.
        *
        */
       PDO_STMT_CLEAR_ERR();

       efree(args);
              
       return retval;
}

Here is the call graph for this function:

Here is the caller graph for this function:

zend_object_iterator* php_pdo_dbstmt_iter_get ( zend_class_entry *  ce,
zval *object  TSRMLS_DC 
)
PDO_API zend_class_entry* php_pdo_get_exception_base ( int root  TSRMLS_DC)

Definition at line 74 of file pdo.c.

{
#if can_handle_soft_dependency_on_SPL && defined(HAVE_SPL) && ((PHP_MAJOR_VERSION > 5) || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 1))
       if (!root) {
              if (!spl_ce_RuntimeException) {
                     zend_class_entry **pce;

                     if (zend_hash_find(CG(class_table), "runtimeexception", sizeof("RuntimeException"), (void **) &pce) == SUCCESS) {
                            spl_ce_RuntimeException = *pce;
                            return *pce;
                     }
              } else {
                     return spl_ce_RuntimeException;
              }
       }
#endif
#if (PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION < 2)
       return zend_exception_get_default();
#else
       return zend_exception_get_default(TSRMLS_C);
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

int php_pdo_list_entry ( void  )

Definition at line 49 of file pdo.c.

{
       return le_ppdo;
}

Here is the caller graph for this function:

ZEND_RSRC_DTOR_FUNC ( php_pdo_pdbh_dtor  )

Definition at line 1594 of file pdo_dbh.c.

{
       if (rsrc->ptr) {
              pdo_dbh_t *dbh = (pdo_dbh_t*)rsrc->ptr;
              dbh_free(dbh TSRMLS_CC);
              rsrc->ptr = NULL;
       }
}

Here is the call graph for this function:


Variable Documentation

zend_class_entry* pdo_dbh_ce

Definition at line 97 of file pdo.c.

zend_class_entry* pdo_dbstmt_ce

Definition at line 97 of file pdo.c.

Definition at line 2221 of file pdo_stmt.c.

zend_object_handlers pdo_dbstmt_object_handlers

Definition at line 2353 of file pdo_stmt.c.

Definition at line 44 of file pdo.c.

zend_class_entry* pdo_exception_ce

Definition at line 55 of file pdo.c.

zend_class_entry* pdo_row_ce

Definition at line 97 of file pdo.c.

Definition at line 2600 of file pdo_stmt.c.

zend_object_handlers pdo_row_object_handlers

Definition at line 2758 of file pdo_stmt.c.