Back to index

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

Go to the source code of this file.

Classes

struct  pdo_odbc_errinfo
struct  pdo_odbc_db_handle
struct  pdo_odbc_column
struct  pdo_odbc_stmt
struct  pdo_odbc_param

Defines

#define PDO_ODBC_TYPE   "Unknown"
#define PDO_ODBC_HENV   HENV
#define PDO_ODBC_HDBC   HDBC
#define PDO_ODBC_HSTMT   HSTMT
#define pdo_odbc_drv_error(what)   pdo_odbc_error(dbh, NULL, SQL_NULL_HSTMT, what, __FILE__, __LINE__ TSRMLS_CC)
#define pdo_odbc_stmt_error(what)   pdo_odbc_error(stmt->dbh, stmt, SQL_NULL_HSTMT, what, __FILE__, __LINE__ TSRMLS_CC)
#define pdo_odbc_doer_error(what)   pdo_odbc_error(dbh, NULL, stmt, what, __FILE__, __LINE__ TSRMLS_CC)

Enumerations

enum  { PDO_ODBC_ATTR_USE_CURSOR_LIBRARY = PDO_ATTR_DRIVER_SPECIFIC, PDO_ODBC_ATTR_ASSUME_UTF8 }

Functions

void pdo_odbc_error (pdo_dbh_t *dbh, pdo_stmt_t *stmt, PDO_ODBC_HSTMT statement, char *what, const char *file, int line TSRMLS_DC)
void pdo_odbc_init_error_table (void)
void pdo_odbc_fini_error_table (void)

Variables

pdo_driver_t pdo_odbc_driver

Class Documentation

struct pdo_odbc_errinfo

Definition at line 120 of file php_pdo_odbc_int.h.

Class Members
const char * file
char last_err_msg
SDWORD last_error
char last_state
int line
const char * what
struct pdo_odbc_db_handle

Definition at line 128 of file php_pdo_odbc_int.h.

Collaboration diagram for pdo_odbc_db_handle:
Class Members
unsigned _spare:31
unsigned assume_utf8:1
PDO_ODBC_HDBC dbc
pdo_odbc_errinfo einfo
PDO_ODBC_HENV env
struct pdo_odbc_column

Definition at line 136 of file php_pdo_odbc_int.h.

Class Members
unsigned _spare:31
char colname
SWORD coltype
char * data
unsigned long datalen
SQLLEN fetched_len
unsigned is_long
unsigned is_unicode:1
struct pdo_odbc_stmt

Definition at line 147 of file php_pdo_odbc_int.h.

Collaboration diagram for pdo_odbc_stmt:
Class Members
unsigned _spare:30
unsigned assume_utf8:1
pdo_odbc_column * cols
char * convbuf
unsigned long convbufsize
pdo_odbc_errinfo einfo
unsigned going_long:1
pdo_odbc_db_handle * H
PDO_ODBC_HSTMT stmt
struct pdo_odbc_param

Definition at line 159 of file php_pdo_odbc_int.h.

Class Members
unsigned _spare:31
unsigned is_unicode:1
SQLINTEGER len
char * outbuf
SQLSMALLINT paramtype

Define Documentation

#define pdo_odbc_doer_error (   what)    pdo_odbc_error(dbh, NULL, stmt, what, __FILE__, __LINE__ TSRMLS_CC)

Definition at line 173 of file php_pdo_odbc_int.h.

#define pdo_odbc_drv_error (   what)    pdo_odbc_error(dbh, NULL, SQL_NULL_HSTMT, what, __FILE__, __LINE__ TSRMLS_CC)

Definition at line 171 of file php_pdo_odbc_int.h.

#define PDO_ODBC_HDBC   HDBC

Definition at line 115 of file php_pdo_odbc_int.h.

#define PDO_ODBC_HENV   HENV

Definition at line 114 of file php_pdo_odbc_int.h.

#define PDO_ODBC_HSTMT   HSTMT

Definition at line 116 of file php_pdo_odbc_int.h.

#define pdo_odbc_stmt_error (   what)    pdo_odbc_error(stmt->dbh, stmt, SQL_NULL_HSTMT, what, __FILE__, __LINE__ TSRMLS_CC)

Definition at line 172 of file php_pdo_odbc_int.h.

#define PDO_ODBC_TYPE   "Unknown"

Definition at line 27 of file php_pdo_odbc_int.h.


Enumeration Type Documentation

anonymous enum
Enumerator:
PDO_ODBC_ATTR_USE_CURSOR_LIBRARY 
PDO_ODBC_ATTR_ASSUME_UTF8 

Definition at line 183 of file php_pdo_odbc_int.h.

     {
       PDO_ODBC_ATTR_USE_CURSOR_LIBRARY = PDO_ATTR_DRIVER_SPECIFIC,
       PDO_ODBC_ATTR_ASSUME_UTF8 /* assume that input strings are UTF-8 when feeding data to unicode columns */
};

Function Documentation

void pdo_odbc_error ( pdo_dbh_t *  dbh,
pdo_stmt_t *  stmt,
PDO_ODBC_HSTMT  statement,
char *  what,
const char *  file,
int line  TSRMLS_DC 
)

Definition at line 59 of file odbc_driver.c.

{
       SQLRETURN rc;
       SQLSMALLINT   errmsgsize = 0;
       SQLHANDLE eh;
       SQLSMALLINT htype, recno = 1;
       pdo_odbc_db_handle *H = (pdo_odbc_db_handle*)dbh->driver_data;
       pdo_odbc_errinfo *einfo = &H->einfo;
       pdo_odbc_stmt *S = NULL;
       pdo_error_type *pdo_err = &dbh->error_code;

       if (stmt) {
              S = (pdo_odbc_stmt*)stmt->driver_data;

              einfo = &S->einfo;
              pdo_err = &stmt->error_code;
       }

       if (statement == SQL_NULL_HSTMT && S) {
              statement = S->stmt;
       }

       if (statement) {
              htype = SQL_HANDLE_STMT;
              eh = statement;
       } else if (H->dbc) {
              htype = SQL_HANDLE_DBC;
              eh = H->dbc;
       } else {
              htype = SQL_HANDLE_ENV;
              eh = H->env;
       }

       rc = SQLGetDiagRec(htype, eh, recno++, einfo->last_state, &einfo->last_error,
                     einfo->last_err_msg, sizeof(einfo->last_err_msg)-1, &errmsgsize);

       if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
              errmsgsize = 0;
       }

       einfo->last_err_msg[errmsgsize] = '\0';
       einfo->file = file;
       einfo->line = line;
       einfo->what = what;

       strcpy(*pdo_err, einfo->last_state);
/* printf("@@ SQLSTATE[%s] %s\n", *pdo_err, einfo->last_err_msg); */
       if (!dbh->methods) {
              zend_throw_exception_ex(php_pdo_get_exception(), einfo->last_error TSRMLS_CC, "SQLSTATE[%s] %s: %d %s",
                            *pdo_err, what, einfo->last_error, einfo->last_err_msg);
       }

       /* just like a cursor, once you start pulling, you need to keep
        * going until the end; SQL Server (at least) will mess with the
        * actual cursor state if you don't finish retrieving all the
        * diagnostic records (which can be generated by PRINT statements
        * in the query, for instance). */
       while (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO) {
              char discard_state[5];
              char discard_buf[1024];
              SQLINTEGER code;
              rc = SQLGetDiagRec(htype, eh, recno++, discard_state, &code,
                            discard_buf, sizeof(discard_buf)-1, &errmsgsize);
       }

}

Here is the call graph for this function:

void pdo_odbc_fini_error_table ( void  )
void pdo_odbc_init_error_table ( void  )

Variable Documentation

Definition at line 481 of file odbc_driver.c.