Cleaned up redundant code (#1260)
This commit is contained in:
parent
7313fa0c8b
commit
5f2a14c8e9
|
@ -1049,7 +1049,7 @@ int pdo_sqlsrv_dbh_set_attr( _Inout_ pdo_dbh_t *dbh, _In_ zend_long attr, _Inout
|
|||
break;
|
||||
|
||||
case SQLSRV_ATTR_DIRECT_QUERY:
|
||||
driver_dbh->direct_query = ( zend_is_true( val ) ) ? true : false;
|
||||
driver_dbh->direct_query = zend_is_true(val);
|
||||
break;
|
||||
|
||||
case SQLSRV_ATTR_QUERY_TIMEOUT:
|
||||
|
@ -1069,15 +1069,15 @@ int pdo_sqlsrv_dbh_set_attr( _Inout_ pdo_dbh_t *dbh, _In_ zend_long attr, _Inout
|
|||
break;
|
||||
|
||||
case SQLSRV_ATTR_FETCHES_NUMERIC_TYPE:
|
||||
driver_dbh->fetch_numeric = (zend_is_true(val)) ? true : false;
|
||||
driver_dbh->fetch_numeric = zend_is_true(val);
|
||||
break;
|
||||
|
||||
case SQLSRV_ATTR_FETCHES_DATETIME_TYPE:
|
||||
driver_dbh->fetch_datetime = (zend_is_true(val)) ? true : false;
|
||||
driver_dbh->fetch_datetime = zend_is_true(val);
|
||||
break;
|
||||
|
||||
case SQLSRV_ATTR_FORMAT_DECIMALS:
|
||||
driver_dbh->format_decimals = (zend_is_true(val)) ? true : false;
|
||||
driver_dbh->format_decimals = zend_is_true(val);
|
||||
break;
|
||||
|
||||
case SQLSRV_ATTR_DECIMAL_PLACES:
|
||||
|
|
|
@ -315,7 +315,7 @@ void stmt_option_encoding:: operator()( _Inout_ sqlsrv_stmt* stmt, stmt_option c
|
|||
void stmt_option_direct_query:: operator()( _Inout_ sqlsrv_stmt* stmt, stmt_option const* /*opt*/, _In_ zval* value_z )
|
||||
{
|
||||
pdo_sqlsrv_stmt *pdo_stmt = static_cast<pdo_sqlsrv_stmt*>( stmt );
|
||||
pdo_stmt->direct_query = ( zend_is_true( value_z )) ? true : false;
|
||||
pdo_stmt->direct_query = zend_is_true(value_z);
|
||||
}
|
||||
|
||||
void stmt_option_cursor_scroll_type:: operator()( _Inout_ sqlsrv_stmt* stmt, stmt_option const* /*opt*/, _In_ zval* value_z )
|
||||
|
@ -332,13 +332,13 @@ void stmt_option_emulate_prepares:: operator()( _Inout_ sqlsrv_stmt* stmt, stmt_
|
|||
void stmt_option_fetch_numeric:: operator()( _Inout_ sqlsrv_stmt* stmt, stmt_option const* /*opt*/, _In_ zval* value_z )
|
||||
{
|
||||
pdo_sqlsrv_stmt *pdo_stmt = static_cast<pdo_sqlsrv_stmt*>( stmt );
|
||||
pdo_stmt->fetch_numeric = ( zend_is_true( value_z )) ? true : false;
|
||||
pdo_stmt->fetch_numeric = zend_is_true(value_z);
|
||||
}
|
||||
|
||||
void stmt_option_fetch_datetime:: operator()( _Inout_ sqlsrv_stmt* stmt, stmt_option const* /*opt*/, _In_ zval* value_z )
|
||||
{
|
||||
pdo_sqlsrv_stmt *pdo_stmt = static_cast<pdo_sqlsrv_stmt*>( stmt );
|
||||
pdo_stmt->fetch_datetime = ( zend_is_true( value_z )) ? true : false;
|
||||
pdo_stmt->fetch_datetime = zend_is_true(value_z);
|
||||
}
|
||||
|
||||
// log a function entry point
|
||||
|
@ -880,15 +880,15 @@ int pdo_sqlsrv_stmt_set_attr( _Inout_ pdo_stmt_t *stmt, _In_ zend_long attr, _In
|
|||
break;
|
||||
|
||||
case SQLSRV_ATTR_FETCHES_NUMERIC_TYPE:
|
||||
driver_stmt->fetch_numeric = ( zend_is_true( val )) ? true : false;
|
||||
driver_stmt->fetch_numeric = zend_is_true(val);
|
||||
break;
|
||||
|
||||
case SQLSRV_ATTR_FETCHES_DATETIME_TYPE:
|
||||
driver_stmt->fetch_datetime = ( zend_is_true( val )) ? true : false;
|
||||
driver_stmt->fetch_datetime = zend_is_true(val);
|
||||
break;
|
||||
|
||||
case SQLSRV_ATTR_FORMAT_DECIMALS:
|
||||
driver_stmt->format_decimals = ( zend_is_true( val )) ? true : false;
|
||||
driver_stmt->format_decimals = zend_is_true(val);
|
||||
break;
|
||||
|
||||
case SQLSRV_ATTR_DECIMAL_PLACES:
|
||||
|
@ -896,7 +896,7 @@ int pdo_sqlsrv_stmt_set_attr( _Inout_ pdo_stmt_t *stmt, _In_ zend_long attr, _In
|
|||
break;
|
||||
|
||||
case SQLSRV_ATTR_DATA_CLASSIFICATION:
|
||||
driver_stmt->data_classification = (zend_is_true(val)) ? true : false;
|
||||
driver_stmt->data_classification = zend_is_true(val);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -1152,22 +1152,12 @@ void stmt_option_buffered_query_limit:: operator()( _Inout_ sqlsrv_stmt* stmt, s
|
|||
|
||||
void stmt_option_date_as_string:: operator()( _Inout_ sqlsrv_stmt* stmt, stmt_option const* /**/, _In_ zval* value_z )
|
||||
{
|
||||
if (zend_is_true(value_z)) {
|
||||
stmt->date_as_string = true;
|
||||
}
|
||||
else {
|
||||
stmt->date_as_string = false;
|
||||
}
|
||||
stmt->date_as_string = zend_is_true(value_z);
|
||||
}
|
||||
|
||||
void stmt_option_format_decimals:: operator()( _Inout_ sqlsrv_stmt* stmt, stmt_option const* /**/, _In_ zval* value_z )
|
||||
{
|
||||
if (zend_is_true(value_z)) {
|
||||
stmt->format_decimals = true;
|
||||
}
|
||||
else {
|
||||
stmt->format_decimals = false;
|
||||
}
|
||||
stmt->format_decimals = zend_is_true(value_z);
|
||||
}
|
||||
|
||||
void stmt_option_decimal_places:: operator()( _Inout_ sqlsrv_stmt* stmt, stmt_option const* /**/, _In_ zval* value_z )
|
||||
|
@ -1177,12 +1167,7 @@ void stmt_option_decimal_places:: operator()( _Inout_ sqlsrv_stmt* stmt, stmt_op
|
|||
|
||||
void stmt_option_data_classification:: operator()( _Inout_ sqlsrv_stmt* stmt, stmt_option const* /**/, _In_ zval* value_z )
|
||||
{
|
||||
if (zend_is_true(value_z)) {
|
||||
stmt->data_classification = true;
|
||||
}
|
||||
else {
|
||||
stmt->data_classification = false;
|
||||
}
|
||||
stmt->data_classification = zend_is_true(value_z);
|
||||
}
|
||||
|
||||
// internal function to release the active stream. Called by each main API function
|
||||
|
|
|
@ -30,6 +30,8 @@ extern "C" {
|
|||
|
||||
namespace {
|
||||
|
||||
const int MAX_CONN_VALSTRING_LEN = 256;
|
||||
|
||||
// current subsytem. defined for the CHECK_SQL_{ERROR|WARNING} macros
|
||||
unsigned int current_log_subsystem = LOG_CONN;
|
||||
|
||||
|
@ -38,13 +40,7 @@ struct date_as_string_func {
|
|||
static void func( connection_option const* /*option*/, _In_ zval* value, _Inout_ sqlsrv_conn* conn, std::string& /*conn_str*/ )
|
||||
{
|
||||
ss_sqlsrv_conn* ss_conn = static_cast<ss_sqlsrv_conn*>( conn );
|
||||
|
||||
if( zend_is_true( value )) {
|
||||
ss_conn->date_as_string = true;
|
||||
}
|
||||
else {
|
||||
ss_conn->date_as_string = false;
|
||||
}
|
||||
ss_conn->date_as_string = zend_is_true(value);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -53,13 +49,7 @@ struct format_decimals_func
|
|||
static void func(connection_option const* /*option*/, _In_ zval* value, _Inout_ sqlsrv_conn* conn, std::string& /*conn_str*/)
|
||||
{
|
||||
ss_sqlsrv_conn* ss_conn = static_cast<ss_sqlsrv_conn*>(conn);
|
||||
|
||||
if (zend_is_true(value)) {
|
||||
ss_conn->format_decimals = true;
|
||||
}
|
||||
else {
|
||||
ss_conn->format_decimals = false;
|
||||
}
|
||||
ss_conn->format_decimals = zend_is_true(value);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -117,17 +107,10 @@ struct bool_conn_str_func {
|
|||
|
||||
static void func( _In_ connection_option const* option, _In_ zval* value, sqlsrv_conn* /*conn*/, _Out_ std::string& conn_str )
|
||||
{
|
||||
char const* val_str;
|
||||
if( zend_is_true( value )) {
|
||||
val_str = "yes";
|
||||
}
|
||||
else {
|
||||
val_str = "no";
|
||||
}
|
||||
conn_str += option->odbc_name;
|
||||
conn_str += "={";
|
||||
conn_str += val_str;
|
||||
conn_str += "};";
|
||||
char temp_str[MAX_CONN_VALSTRING_LEN];
|
||||
|
||||
snprintf(temp_str, MAX_CONN_VALSTRING_LEN, "%s={%s};", option->odbc_name, (zend_is_true(value) ? "yes" : "no"));
|
||||
conn_str += temp_str;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -137,12 +120,10 @@ struct int_conn_str_func {
|
|||
{
|
||||
SQLSRV_ASSERT( Z_TYPE_P( value ) == IS_LONG, "An integer is expected for this keyword" )
|
||||
|
||||
std::string val_str = std::to_string( Z_LVAL_P( value ));
|
||||
|
||||
conn_str += option->odbc_name;
|
||||
conn_str += "={";
|
||||
conn_str += val_str;
|
||||
conn_str += "};";
|
||||
char temp_str[MAX_CONN_VALSTRING_LEN];
|
||||
|
||||
snprintf(temp_str, MAX_CONN_VALSTRING_LEN, "%s={%d};", option->odbc_name, Z_LVAL_P(value));
|
||||
conn_str += temp_str;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue