Spacing fixes
This commit is contained in:
parent
e785329f16
commit
def3ae8375
|
@ -69,7 +69,7 @@ enum PDO_STMT_OPTIONS {
|
|||
PDO_STMT_OPTION_CURSOR_SCROLL_TYPE,
|
||||
PDO_STMT_OPTION_CLIENT_BUFFER_MAX_KB_SIZE,
|
||||
PDO_STMT_OPTION_EMULATE_PREPARES,
|
||||
PDO_STMT_OPTION_FETCHES_NUMERIC_TYPE,
|
||||
PDO_STMT_OPTION_FETCHES_NUMERIC_TYPE,
|
||||
};
|
||||
|
||||
// List of all the statement options supported by this driver.
|
||||
|
@ -82,9 +82,9 @@ const stmt_option PDO_STMT_OPTS[] = {
|
|||
{ NULL, 0, PDO_STMT_OPTION_CURSOR_SCROLL_TYPE, std::unique_ptr<stmt_option_cursor_scroll_type>( new stmt_option_cursor_scroll_type ) },
|
||||
{ NULL, 0, PDO_STMT_OPTION_CLIENT_BUFFER_MAX_KB_SIZE, std::unique_ptr<stmt_option_buffered_query_limit>( new stmt_option_buffered_query_limit ) },
|
||||
{ NULL, 0, PDO_STMT_OPTION_EMULATE_PREPARES, std::unique_ptr<stmt_option_emulate_prepares>( new stmt_option_emulate_prepares ) },
|
||||
{ NULL, 0, PDO_STMT_OPTION_FETCHES_NUMERIC_TYPE, std::unique_ptr<stmt_option_fetch_numeric>( new stmt_option_fetch_numeric ) },
|
||||
{ NULL, 0, PDO_STMT_OPTION_FETCHES_NUMERIC_TYPE, std::unique_ptr<stmt_option_fetch_numeric>( new stmt_option_fetch_numeric ) },
|
||||
|
||||
{ NULL, 0, SQLSRV_STMT_OPTION_INVALID, std::unique_ptr<stmt_option_functor>{} },
|
||||
{ NULL, 0, SQLSRV_STMT_OPTION_INVALID, std::unique_ptr<stmt_option_functor>{} },
|
||||
};
|
||||
|
||||
// boolean connection string
|
||||
|
@ -346,7 +346,7 @@ struct pdo_dbh_methods pdo_sqlsrv_dbh_methods = {
|
|||
NULL, // check liveness not implemented
|
||||
pdo_sqlsrv_get_driver_methods,
|
||||
NULL, // request shutdown not implemented
|
||||
NULL // in transaction not implemented
|
||||
NULL // in transaction not implemented
|
||||
};
|
||||
|
||||
|
||||
|
@ -373,13 +373,13 @@ struct pdo_dbh_methods pdo_sqlsrv_dbh_methods = {
|
|||
|
||||
// constructor for the internal object for connections
|
||||
pdo_sqlsrv_dbh::pdo_sqlsrv_dbh( SQLHANDLE h, error_callback e, void* driver TSRMLS_DC ) :
|
||||
sqlsrv_conn( h, e, driver, SQLSRV_ENCODING_UTF8 TSRMLS_CC ),
|
||||
stmts( NULL ),
|
||||
direct_query( false ),
|
||||
query_timeout( QUERY_TIMEOUT_INVALID ),
|
||||
client_buffer_max_size( PDO_SQLSRV_G( client_buffer_max_size )),
|
||||
bind_param_encoding( SQLSRV_ENCODING_CHAR ),
|
||||
fetch_numeric( false )
|
||||
sqlsrv_conn( h, e, driver, SQLSRV_ENCODING_UTF8 TSRMLS_CC ),
|
||||
stmts( NULL ),
|
||||
direct_query( false ),
|
||||
query_timeout( QUERY_TIMEOUT_INVALID ),
|
||||
client_buffer_max_size( PDO_SQLSRV_G( client_buffer_max_size )),
|
||||
bind_param_encoding( SQLSRV_ENCODING_CHAR ),
|
||||
fetch_numeric( false )
|
||||
{
|
||||
if( client_buffer_max_size < 0 ) {
|
||||
client_buffer_max_size = sqlsrv_buffered_result_set::BUFFERED_QUERY_LIMIT_DEFAULT;
|
||||
|
@ -417,7 +417,7 @@ int pdo_sqlsrv_db_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_DC)
|
|||
zval* temp_server_z = NULL;
|
||||
sqlsrv_malloc_auto_ptr<conn_string_parser> dsn_parser;
|
||||
zval server_z;
|
||||
ZVAL_UNDEF( &server_z );
|
||||
ZVAL_UNDEF( &server_z );
|
||||
|
||||
try {
|
||||
|
||||
|
@ -461,8 +461,8 @@ int pdo_sqlsrv_db_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_DC)
|
|||
dbh->username, dbh->password, pdo_conn_options_ht, pdo_sqlsrv_handle_dbh_error,
|
||||
PDO_CONN_OPTS, dbh, "pdo_sqlsrv_db_handle_factory" TSRMLS_CC );
|
||||
|
||||
// Free the string in server_z after being used
|
||||
zend_string_release( Z_STR( server_z ));
|
||||
// Free the string in server_z after being used
|
||||
zend_string_release( Z_STR( server_z ));
|
||||
|
||||
SQLSRV_ASSERT( conn != NULL, "Invalid connection returned. Exception should have been thrown." );
|
||||
|
||||
|
@ -475,11 +475,11 @@ int pdo_sqlsrv_db_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_DC)
|
|||
}
|
||||
catch( core::CoreException& ) {
|
||||
|
||||
if ( Z_TYPE( server_z ) == IS_STRING ) {
|
||||
zend_string_release( Z_STR( server_z ));
|
||||
}
|
||||
if ( Z_TYPE( server_z ) == IS_STRING ) {
|
||||
zend_string_release( Z_STR( server_z ));
|
||||
}
|
||||
dbh->error_mode = prev_err_mode; // reset the error mode
|
||||
g_henv_cp->last_error().reset(); // reset the last error; callee will check if last_error exist before freeing it and setting it to NULL
|
||||
g_henv_cp->last_error().reset(); // reset the last error; callee will check if last_error exist before freeing it and setting it to NULL
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -931,7 +931,7 @@ int pdo_sqlsrv_dbh_set_attr( pdo_dbh_t *dbh, zend_long attr, zval *val TSRMLS_DC
|
|||
case PDO_ATTR_FETCH_CATALOG_NAMES:
|
||||
case PDO_ATTR_PREFETCH:
|
||||
case PDO_ATTR_MAX_COLUMN_LEN:
|
||||
case PDO_ATTR_CURSOR_NAME:
|
||||
case PDO_ATTR_CURSOR_NAME:
|
||||
case PDO_ATTR_AUTOCOMMIT:
|
||||
case PDO_ATTR_PERSISTENT:
|
||||
case PDO_ATTR_TIMEOUT:
|
||||
|
@ -941,10 +941,10 @@ int pdo_sqlsrv_dbh_set_attr( pdo_dbh_t *dbh, zend_long attr, zval *val TSRMLS_DC
|
|||
|
||||
// Read-only
|
||||
case PDO_ATTR_SERVER_VERSION:
|
||||
case PDO_ATTR_SERVER_INFO:
|
||||
case PDO_ATTR_SERVER_INFO:
|
||||
case PDO_ATTR_CLIENT_VERSION:
|
||||
case PDO_ATTR_DRIVER_NAME:
|
||||
case PDO_ATTR_CONNECTION_STATUS:
|
||||
case PDO_ATTR_CONNECTION_STATUS:
|
||||
{
|
||||
THROW_PDO_ERROR( driver_dbh, PDO_SQLSRV_ERROR_READ_ONLY_DBH_ATTR );
|
||||
}
|
||||
|
@ -952,7 +952,7 @@ int pdo_sqlsrv_dbh_set_attr( pdo_dbh_t *dbh, zend_long attr, zval *val TSRMLS_DC
|
|||
// Statement level only
|
||||
case PDO_ATTR_EMULATE_PREPARES:
|
||||
case PDO_ATTR_CURSOR:
|
||||
case SQLSRV_ATTR_CURSOR_SCROLL_TYPE:
|
||||
case SQLSRV_ATTR_CURSOR_SCROLL_TYPE:
|
||||
{
|
||||
THROW_PDO_ERROR( driver_dbh, PDO_SQLSRV_ERROR_STMT_LEVEL_ATTR );
|
||||
}
|
||||
|
@ -1009,7 +1009,7 @@ int pdo_sqlsrv_dbh_get_attr( pdo_dbh_t *dbh, zend_long attr, zval *return_value
|
|||
// Statement level only
|
||||
case PDO_ATTR_EMULATE_PREPARES:
|
||||
case PDO_ATTR_CURSOR:
|
||||
case SQLSRV_ATTR_CURSOR_SCROLL_TYPE:
|
||||
case SQLSRV_ATTR_CURSOR_SCROLL_TYPE:
|
||||
{
|
||||
THROW_PDO_ERROR( driver_dbh, PDO_SQLSRV_ERROR_STMT_LEVEL_ATTR );
|
||||
}
|
||||
|
@ -1070,11 +1070,11 @@ int pdo_sqlsrv_dbh_get_attr( pdo_dbh_t *dbh, zend_long attr, zval *return_value
|
|||
break;
|
||||
}
|
||||
|
||||
case SQLSRV_ATTR_FETCHES_NUMERIC_TYPE:
|
||||
{
|
||||
ZVAL_BOOL( return_value, driver_dbh->fetch_numeric );
|
||||
break;
|
||||
}
|
||||
case SQLSRV_ATTR_FETCHES_NUMERIC_TYPE:
|
||||
{
|
||||
ZVAL_BOOL( return_value, driver_dbh->fetch_numeric );
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
|
@ -1150,7 +1150,7 @@ char * pdo_sqlsrv_dbh_last_id( pdo_dbh_t *dbh, const char *name, _Out_ size_t* l
|
|||
}
|
||||
else {
|
||||
char* quoted_table = NULL;
|
||||
size_t quoted_len = 0;
|
||||
size_t quoted_len = 0;
|
||||
int quoted = pdo_sqlsrv_dbh_quote( dbh, name, strlen( name ), "ed_table, "ed_len, PDO_PARAM_NULL TSRMLS_CC );
|
||||
SQLSRV_ASSERT( quoted, "PDO::lastInsertId failed to quote the table name.");
|
||||
snprintf( last_insert_id_query, LAST_INSERT_ID_QUERY_MAX_LEN, TABLE_LAST_INSERT_ID_QUERY, quoted_table );
|
||||
|
@ -1173,7 +1173,7 @@ char * pdo_sqlsrv_dbh_last_id( pdo_dbh_t *dbh, const char *name, _Out_ size_t* l
|
|||
SQLRETURN r = core::SQLGetData( driver_stmt, 1, SQL_C_CHAR, id_str, LAST_INSERT_ID_BUFF_LEN,
|
||||
reinterpret_cast<SQLLEN*>( len ), false TSRMLS_CC );
|
||||
|
||||
CHECK_CUSTOM_ERROR( (!SQL_SUCCEEDED( r ) || *len == SQL_NULL_DATA || *len == SQL_NO_TOTAL), driver_stmt,
|
||||
CHECK_CUSTOM_ERROR( (!SQL_SUCCEEDED( r ) || *len == SQL_NULL_DATA || *len == SQL_NO_TOTAL), driver_stmt,
|
||||
PDO_SQLSRV_ERROR_LAST_INSERT_ID ) {
|
||||
throw core::CoreException();
|
||||
}
|
||||
|
@ -1271,7 +1271,7 @@ int pdo_sqlsrv_dbh_quote( pdo_dbh_t* dbh, const char* unquoted, size_t unquoted_
|
|||
|
||||
// insert N if the encoding is UTF8
|
||||
if ( encoding == SQLSRV_ENCODING_UTF8 ) {
|
||||
( *quoted )[ out_current++ ] = 'N';
|
||||
( *quoted )[ out_current++ ] = 'N';
|
||||
}
|
||||
// insert initial quote
|
||||
( *quoted )[ out_current++ ] = '\'';
|
||||
|
@ -1283,7 +1283,7 @@ int pdo_sqlsrv_dbh_quote( pdo_dbh_t* dbh, const char* unquoted, size_t unquoted_
|
|||
}
|
||||
else {
|
||||
( *quoted )[ out_current++ ] = unquoted[ index ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// trailing quote and null terminator
|
||||
|
@ -1306,7 +1306,7 @@ pdo_sqlsrv_function_entry *pdo_sqlsrv_get_driver_methods( pdo_dbh_t *dbh, int ki
|
|||
return NULL;
|
||||
}
|
||||
|
||||
return NULL; // to avoid a compiler warning
|
||||
return NULL; // to avoid a compiler warning
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@ -1384,20 +1384,20 @@ void validate_stmt_options( sqlsrv_context& ctx, zval* stmt_options, _Inout_ Has
|
|||
if( stmt_options ) {
|
||||
|
||||
HashTable* options_ht = Z_ARRVAL_P( stmt_options );
|
||||
size_t int_key = -1;
|
||||
zend_string *key = NULL;
|
||||
zval* data = NULL;
|
||||
size_t int_key = -1;
|
||||
zend_string *key = NULL;
|
||||
zval* data = NULL;
|
||||
|
||||
ZEND_HASH_FOREACH_KEY_VAL( options_ht, int_key, key, data ) {
|
||||
int type = HASH_KEY_NON_EXISTENT;
|
||||
int result = 0;
|
||||
type = key ? HASH_KEY_IS_STRING : HASH_KEY_IS_LONG;
|
||||
CHECK_CUSTOM_ERROR(( type != HASH_KEY_IS_LONG ), ctx, PDO_SQLSRV_ERROR_INVALID_STMT_OPTION ) {
|
||||
throw core::CoreException();
|
||||
}
|
||||
ZEND_HASH_FOREACH_KEY_VAL( options_ht, int_key, key, data ) {
|
||||
int type = HASH_KEY_NON_EXISTENT;
|
||||
int result = 0;
|
||||
type = key ? HASH_KEY_IS_STRING : HASH_KEY_IS_LONG;
|
||||
CHECK_CUSTOM_ERROR(( type != HASH_KEY_IS_LONG ), ctx, PDO_SQLSRV_ERROR_INVALID_STMT_OPTION ) {
|
||||
throw core::CoreException();
|
||||
}
|
||||
|
||||
add_stmt_option_key( ctx, int_key, pdo_stmt_options_ht, data TSRMLS_CC );
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
add_stmt_option_key( ctx, int_key, pdo_stmt_options_ht, data TSRMLS_CC );
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
}
|
||||
}
|
||||
catch( core::CoreException& ) {
|
||||
|
|
|
@ -61,8 +61,8 @@ extern sqlsrv_attr_pdo_constant pdo_attr_constants[];
|
|||
}
|
||||
|
||||
static zend_module_dep pdo_sqlsrv_depends[] = {
|
||||
ZEND_MOD_REQUIRED("pdo")
|
||||
{NULL, NULL, NULL}
|
||||
ZEND_MOD_REQUIRED("pdo")
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
|
@ -81,7 +81,7 @@ zend_module_entry g_pdo_sqlsrv_module_entry =
|
|||
{
|
||||
STANDARD_MODULE_HEADER_EX,
|
||||
NULL,
|
||||
pdo_sqlsrv_depends,
|
||||
pdo_sqlsrv_depends,
|
||||
"pdo_sqlsrv",
|
||||
pdo_sqlsrv_functions, // exported function table
|
||||
// initialization and shutdown functions
|
||||
|
@ -101,8 +101,8 @@ zend_module_entry g_pdo_sqlsrv_module_entry =
|
|||
|
||||
// called by Zend for each parameter in the g_pdo_errors_ht hash table when it is destroyed
|
||||
void pdo_error_dtor(zval* elem) {
|
||||
pdo_error* error_to_ignore = reinterpret_cast<pdo_error*>(Z_PTR_P(elem));
|
||||
pefree(error_to_ignore, 1);
|
||||
pdo_error* error_to_ignore = reinterpret_cast<pdo_error*>(Z_PTR_P(elem));
|
||||
pefree(error_to_ignore, 1);
|
||||
}
|
||||
|
||||
// Module initialization
|
||||
|
@ -115,9 +115,9 @@ PHP_MINIT_FUNCTION(pdo_sqlsrv)
|
|||
// our global variables are initialized in the RINIT function
|
||||
#if defined(ZTS)
|
||||
if( ts_allocate_id( &pdo_sqlsrv_globals_id,
|
||||
sizeof( zend_pdo_sqlsrv_globals ),
|
||||
(ts_allocate_ctor) NULL,
|
||||
(ts_allocate_dtor) NULL ) == 0 )
|
||||
sizeof( zend_pdo_sqlsrv_globals ),
|
||||
(ts_allocate_ctor) NULL,
|
||||
(ts_allocate_dtor) NULL ) == 0 )
|
||||
return FAILURE;
|
||||
ZEND_TSRMLS_CACHE_UPDATE();
|
||||
#endif
|
||||
|
@ -278,13 +278,13 @@ namespace {
|
|||
// array of pdo constants.
|
||||
sqlsrv_attr_pdo_constant pdo_attr_constants[] = {
|
||||
|
||||
// driver specific attributes
|
||||
{ "SQLSRV_ATTR_ENCODING" , SQLSRV_ATTR_ENCODING },
|
||||
{ "SQLSRV_ATTR_QUERY_TIMEOUT" , SQLSRV_ATTR_QUERY_TIMEOUT },
|
||||
{ "SQLSRV_ATTR_DIRECT_QUERY" , SQLSRV_ATTR_DIRECT_QUERY },
|
||||
{ "SQLSRV_ATTR_CURSOR_SCROLL_TYPE" , SQLSRV_ATTR_CURSOR_SCROLL_TYPE },
|
||||
{ "SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE", SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE },
|
||||
{ "SQLSRV_ATTR_FETCHES_NUMERIC_TYPE", SQLSRV_ATTR_FETCHES_NUMERIC_TYPE },
|
||||
// driver specific attributes
|
||||
{ "SQLSRV_ATTR_ENCODING" , SQLSRV_ATTR_ENCODING },
|
||||
{ "SQLSRV_ATTR_QUERY_TIMEOUT" , SQLSRV_ATTR_QUERY_TIMEOUT },
|
||||
{ "SQLSRV_ATTR_DIRECT_QUERY" , SQLSRV_ATTR_DIRECT_QUERY },
|
||||
{ "SQLSRV_ATTR_CURSOR_SCROLL_TYPE" , SQLSRV_ATTR_CURSOR_SCROLL_TYPE },
|
||||
{ "SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE", SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE },
|
||||
{ "SQLSRV_ATTR_FETCHES_NUMERIC_TYPE", SQLSRV_ATTR_FETCHES_NUMERIC_TYPE },
|
||||
|
||||
// used for the size for output parameters: PDO::PARAM_INT and PDO::PARAM_BOOL use the default size of int,
|
||||
// PDO::PARAM_STR uses the size of the string in the variable
|
||||
|
|
|
@ -204,9 +204,9 @@ void set_stmt_encoding( sqlsrv_stmt* stmt, zval* value_z TSRMLS_DC )
|
|||
// internal helper function to free meta data structures allocated
|
||||
void meta_data_free( field_meta_data* meta )
|
||||
{
|
||||
if( meta->field_name ) {
|
||||
meta->field_name.reset();
|
||||
}
|
||||
if( meta->field_name ) {
|
||||
meta->field_name.reset();
|
||||
}
|
||||
sqlsrv_free( meta );
|
||||
}
|
||||
|
||||
|
@ -455,7 +455,7 @@ int pdo_sqlsrv_stmt_describe_col(pdo_stmt_t *stmt, int colno TSRMLS_DC)
|
|||
|
||||
// Set the name
|
||||
column_data->name = zend_string_init( (const char*)core_meta_data->field_name.get(), core_meta_data->field_name_len, 0 );
|
||||
core_meta_data->field_name.reset();
|
||||
core_meta_data->field_name.reset();
|
||||
|
||||
// Set the maxlen
|
||||
column_data->maxlen = ( core_meta_data->field_precision > 0 ) ? core_meta_data->field_precision : core_meta_data->field_size;
|
||||
|
@ -720,7 +720,7 @@ int pdo_sqlsrv_stmt_get_col_data(pdo_stmt_t *stmt, int colno,
|
|||
"Invalid column number in pdo_sqlsrv_stmt_get_col_data" );
|
||||
sqlsrv_php_type = driver_stmt->sql_type_to_php_type( static_cast<SQLUINTEGER>( driver_stmt->current_meta_data[ colno ]->field_type ),
|
||||
static_cast<SQLUINTEGER>( driver_stmt->current_meta_data[ colno ]->field_size ),
|
||||
true );
|
||||
true );
|
||||
|
||||
// set the encoding if the user specified one via bindColumn, otherwise use the statement's encoding
|
||||
sqlsrv_php_type.typeinfo.encoding = driver_stmt->encoding();
|
||||
|
@ -829,9 +829,9 @@ int pdo_sqlsrv_stmt_set_attr(pdo_stmt_t *stmt, zend_long attr, zval *val TSRMLS_
|
|||
core_sqlsrv_set_buffered_query_limit( driver_stmt, val TSRMLS_CC );
|
||||
break;
|
||||
|
||||
case SQLSRV_ATTR_FETCHES_NUMERIC_TYPE:
|
||||
driver_stmt->fetch_numeric = ( zend_is_true( val )) ? true : false;
|
||||
break;
|
||||
case SQLSRV_ATTR_FETCHES_NUMERIC_TYPE:
|
||||
driver_stmt->fetch_numeric = ( zend_is_true( val )) ? true : false;
|
||||
break;
|
||||
|
||||
default:
|
||||
THROW_PDO_ERROR( driver_stmt, PDO_SQLSRV_ERROR_INVALID_STMT_ATTR );
|
||||
|
@ -1095,8 +1095,8 @@ int pdo_sqlsrv_stmt_param_hook(pdo_stmt_t *stmt,
|
|||
case PDO_PARAM_EVT_ALLOC:
|
||||
// if emulate prepare is on, set the bind_param_encoding so it can be used in PDO::quote when binding parameters on the client side
|
||||
if ( stmt->supports_placeholders == PDO_PLACEHOLDER_NONE ) {
|
||||
pdo_sqlsrv_dbh* driver_dbh = reinterpret_cast<pdo_sqlsrv_dbh*>( stmt->dbh->driver_data );
|
||||
driver_dbh->bind_param_encoding = static_cast<SQLSRV_ENCODING>( Z_LVAL( param->driver_params ));
|
||||
pdo_sqlsrv_dbh* driver_dbh = reinterpret_cast<pdo_sqlsrv_dbh*>( stmt->dbh->driver_data );
|
||||
driver_dbh->bind_param_encoding = static_cast<SQLSRV_ENCODING>( Z_LVAL( param->driver_params ));
|
||||
}
|
||||
break;
|
||||
case PDO_PARAM_EVT_FREE:
|
||||
|
@ -1256,7 +1256,7 @@ int pdo_sqlsrv_stmt_param_hook(pdo_stmt_t *stmt,
|
|||
if( !param->is_param ) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
core_sqlsrv_post_param( reinterpret_cast<sqlsrv_stmt*>( stmt->driver_data ), param->paramno,
|
||||
&(param->parameter) TSRMLS_CC );
|
||||
}
|
||||
|
@ -1298,28 +1298,28 @@ sqlsrv_phptype pdo_sqlsrv_stmt::sql_type_to_php_type( SQLINTEGER sql_type, SQLUI
|
|||
}
|
||||
|
||||
switch( sql_type ) {
|
||||
case SQL_BIT:
|
||||
case SQL_INTEGER:
|
||||
case SQL_SMALLINT:
|
||||
case SQL_TINYINT:
|
||||
if ( this->fetch_numeric ) {
|
||||
sqlsrv_phptype.typeinfo.type = SQLSRV_PHPTYPE_INT;
|
||||
}
|
||||
else {
|
||||
sqlsrv_phptype.typeinfo.type = SQLSRV_PHPTYPE_STRING;
|
||||
sqlsrv_phptype.typeinfo.encoding = local_encoding;
|
||||
}
|
||||
break;
|
||||
case SQL_FLOAT:
|
||||
case SQL_REAL:
|
||||
if ( this->fetch_numeric ) {
|
||||
sqlsrv_phptype.typeinfo.type = SQLSRV_PHPTYPE_FLOAT;
|
||||
}
|
||||
else {
|
||||
sqlsrv_phptype.typeinfo.type = SQLSRV_PHPTYPE_STRING;
|
||||
sqlsrv_phptype.typeinfo.encoding = local_encoding;
|
||||
}
|
||||
break;
|
||||
case SQL_BIT:
|
||||
case SQL_INTEGER:
|
||||
case SQL_SMALLINT:
|
||||
case SQL_TINYINT:
|
||||
if ( this->fetch_numeric ) {
|
||||
sqlsrv_phptype.typeinfo.type = SQLSRV_PHPTYPE_INT;
|
||||
}
|
||||
else {
|
||||
sqlsrv_phptype.typeinfo.type = SQLSRV_PHPTYPE_STRING;
|
||||
sqlsrv_phptype.typeinfo.encoding = local_encoding;
|
||||
}
|
||||
break;
|
||||
case SQL_FLOAT:
|
||||
case SQL_REAL:
|
||||
if ( this->fetch_numeric ) {
|
||||
sqlsrv_phptype.typeinfo.type = SQLSRV_PHPTYPE_FLOAT;
|
||||
}
|
||||
else {
|
||||
sqlsrv_phptype.typeinfo.type = SQLSRV_PHPTYPE_STRING;
|
||||
sqlsrv_phptype.typeinfo.encoding = local_encoding;
|
||||
}
|
||||
break;
|
||||
case SQL_BIGINT:
|
||||
case SQL_CHAR:
|
||||
case SQL_DECIMAL:
|
||||
|
|
|
@ -376,8 +376,8 @@ pdo_error PDO_ERRORS[] = {
|
|||
// Returns a sqlsrv_error for a given error code.
|
||||
sqlsrv_error_const* get_error_message(unsigned int sqlsrv_error_code) {
|
||||
|
||||
sqlsrv_error_const *error_message = NULL;
|
||||
int zr = (error_message = reinterpret_cast<sqlsrv_error_const*>(zend_hash_index_find_ptr(g_pdo_errors_ht, sqlsrv_error_code))) != NULL ? SUCCESS : FAILURE;
|
||||
sqlsrv_error_const *error_message = NULL;
|
||||
int zr = (error_message = reinterpret_cast<sqlsrv_error_const*>(zend_hash_index_find_ptr(g_pdo_errors_ht, sqlsrv_error_code))) != NULL ? SUCCESS : FAILURE;
|
||||
if( zr == FAILURE ) {
|
||||
DIE( "get_error_message: zend_hash_index_find returned failure for sqlsrv_error_code = %1!d!", sqlsrv_error_code );
|
||||
}
|
||||
|
@ -448,8 +448,8 @@ bool pdo_sqlsrv_handle_dbh_error( sqlsrv_context& ctx, unsigned int sqlsrv_error
|
|||
SQLSRV_ASSERT( err == true, "No ODBC error was found" );
|
||||
}
|
||||
|
||||
SQLSRV_ASSERT(strlen(reinterpret_cast<const char*>(error->sqlstate)) <= sizeof(dbh->error_code), "Error code overflow");
|
||||
strcpy_s(dbh->error_code, sizeof(dbh->error_code), reinterpret_cast<const char*>(error->sqlstate));
|
||||
SQLSRV_ASSERT(strlen(reinterpret_cast<const char*>(error->sqlstate)) <= sizeof(dbh->error_code), "Error code overflow");
|
||||
strcpy_s(dbh->error_code, sizeof(dbh->error_code), reinterpret_cast<const char*>(error->sqlstate));
|
||||
|
||||
switch( dbh->error_mode ) {
|
||||
case PDO_ERRMODE_EXCEPTION:
|
||||
|
@ -463,9 +463,9 @@ bool pdo_sqlsrv_handle_dbh_error( sqlsrv_context& ctx, unsigned int sqlsrv_error
|
|||
if( !warning ) {
|
||||
size_t msg_len = strlen( reinterpret_cast<const char*>( error->native_message )) + SQL_SQLSTATE_BUFSIZE
|
||||
+ MAX_DIGITS + WARNING_MIN_LENGTH + 1;
|
||||
sqlsrv_malloc_auto_ptr<char> msg;
|
||||
msg = static_cast<char*>( sqlsrv_malloc( msg_len ) );
|
||||
core_sqlsrv_format_message( msg, static_cast<unsigned int>( msg_len ), WARNING_TEMPLATE, error->sqlstate, error->native_code,
|
||||
sqlsrv_malloc_auto_ptr<char> msg;
|
||||
msg = static_cast<char*>( sqlsrv_malloc( msg_len ) );
|
||||
core_sqlsrv_format_message( msg, static_cast<unsigned int>( msg_len ), WARNING_TEMPLATE, error->sqlstate, error->native_code,
|
||||
error->native_message );
|
||||
php_error( E_WARNING, msg );
|
||||
}
|
||||
|
@ -587,15 +587,15 @@ void pdo_sqlsrv_throw_exception( sqlsrv_error_const* error TSRMLS_DC )
|
|||
add_next_index_string( &ex_error_info, reinterpret_cast<char*>( error->sqlstate ));
|
||||
add_next_index_long( &ex_error_info, error->native_code );
|
||||
add_next_index_string( &ex_error_info, reinterpret_cast<char*>( error->native_message ));
|
||||
//zend_update_property makes an entry in the properties_table in ex_obj point to the Z_ARRVAL( ex_error_info )
|
||||
//and the refcount of the zend_array is incremented by 1
|
||||
//zend_update_property makes an entry in the properties_table in ex_obj point to the Z_ARRVAL( ex_error_info )
|
||||
//and the refcount of the zend_array is incremented by 1
|
||||
zend_update_property( ex_class, &ex_obj, EXCEPTION_PROPERTY_ERRORINFO, sizeof( EXCEPTION_PROPERTY_ERRORINFO ) - 1,
|
||||
&ex_error_info TSRMLS_CC );
|
||||
|
||||
//DELREF ex_error_info here to decrement the refcount of the zend_array is 1
|
||||
//the global hashtable EG(exception) then points to the zend_object in ex_obj in zend_throw_exception_object;
|
||||
//this ensure when EG(exception) cleans itself at php shutdown, the zend_array allocated is properly destroyed
|
||||
Z_DELREF( ex_error_info );
|
||||
//DELREF ex_error_info here to decrement the refcount of the zend_array is 1
|
||||
//the global hashtable EG(exception) then points to the zend_object in ex_obj in zend_throw_exception_object;
|
||||
//this ensure when EG(exception) cleans itself at php shutdown, the zend_array allocated is properly destroyed
|
||||
Z_DELREF( ex_error_info );
|
||||
zend_throw_exception_object( &ex_obj TSRMLS_CC );
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ enum PDO_SQLSRV_ATTR {
|
|||
SQLSRV_ATTR_DIRECT_QUERY,
|
||||
SQLSRV_ATTR_CURSOR_SCROLL_TYPE,
|
||||
SQLSRV_ATTR_CLIENT_BUFFER_MAX_KB_SIZE,
|
||||
SQLSRV_ATTR_FETCHES_NUMERIC_TYPE,
|
||||
SQLSRV_ATTR_FETCHES_NUMERIC_TYPE,
|
||||
};
|
||||
|
||||
// valid set of values for TransactionIsolation connection option
|
||||
|
@ -178,8 +178,8 @@ struct pdo_sqlsrv_dbh : public sqlsrv_conn {
|
|||
bool direct_query;
|
||||
long query_timeout;
|
||||
zend_long client_buffer_max_size;
|
||||
SQLSRV_ENCODING bind_param_encoding;
|
||||
bool fetch_numeric;
|
||||
SQLSRV_ENCODING bind_param_encoding;
|
||||
bool fetch_numeric;
|
||||
|
||||
pdo_sqlsrv_dbh( SQLHANDLE h, error_callback e, void* driver TSRMLS_DC );
|
||||
};
|
||||
|
@ -229,11 +229,11 @@ struct pdo_sqlsrv_stmt : public sqlsrv_stmt {
|
|||
direct_query_subst_string( NULL ),
|
||||
direct_query_subst_string_len( 0 ),
|
||||
bound_column_param_types( NULL ),
|
||||
fetch_numeric( false )
|
||||
fetch_numeric( false )
|
||||
{
|
||||
pdo_sqlsrv_dbh* db = static_cast<pdo_sqlsrv_dbh*>( c );
|
||||
direct_query = db->direct_query;
|
||||
fetch_numeric = db->fetch_numeric;
|
||||
fetch_numeric = db->fetch_numeric;
|
||||
}
|
||||
|
||||
virtual ~pdo_sqlsrv_stmt( void );
|
||||
|
@ -249,7 +249,7 @@ struct pdo_sqlsrv_stmt : public sqlsrv_stmt {
|
|||
// meta data for current result set
|
||||
std::vector<field_meta_data*, sqlsrv_allocator< field_meta_data* > > current_meta_data;
|
||||
pdo_param_type* bound_column_param_types;
|
||||
bool fetch_numeric;
|
||||
bool fetch_numeric;
|
||||
};
|
||||
|
||||
|
||||
|
@ -400,5 +400,5 @@ namespace pdo {
|
|||
// logger for pdo_sqlsrv called by the core layer when it wants to log something with the LOG macro
|
||||
void pdo_sqlsrv_log( unsigned int severity TSRMLS_DC, const char* msg, va_list* print_args );
|
||||
|
||||
#endif /* PHP_PDO_SQLSRV_H */
|
||||
#endif /* PHP_PDO_SQLSRV_H */
|
||||
|
||||
|
|
Loading…
Reference in a new issue