change encoding to SYSTEM when converting int to string for inout and output param
This commit is contained in:
parent
a0e886273f
commit
c30f2d6100
|
@ -1433,7 +1433,7 @@ typedef sqlsrv_stmt* (*driver_stmt_factory)( sqlsrv_conn* conn, SQLHANDLE h, err
|
|||
sqlsrv_stmt* core_sqlsrv_create_stmt( _Inout_ sqlsrv_conn* conn, _In_ driver_stmt_factory stmt_factory, _In_opt_ HashTable* options_ht,
|
||||
_In_opt_ const stmt_option valid_stmt_opts[], _In_ error_callback const err, _In_opt_ void* driver TSRMLS_DC );
|
||||
void core_sqlsrv_bind_param( _Inout_ sqlsrv_stmt* stmt, _In_ SQLUSMALLINT param_num, _In_ SQLSMALLINT direction, _Inout_ zval* param_z,
|
||||
_In_ SQLSRV_PHPTYPE php_out_type, _In_ SQLSRV_ENCODING encoding, _Inout_ SQLSMALLINT sql_type, _Inout_ SQLULEN column_size,
|
||||
_In_ SQLSRV_PHPTYPE php_out_type, _Inout_ SQLSRV_ENCODING encoding, _Inout_ SQLSMALLINT sql_type, _Inout_ SQLULEN column_size,
|
||||
_Inout_ SQLSMALLINT decimal_digits TSRMLS_DC );
|
||||
SQLRETURN core_sqlsrv_execute( _Inout_ sqlsrv_stmt* stmt TSRMLS_DC, _In_reads_bytes_(sql_len) const char* sql = NULL, _In_ int sql_len = 0 );
|
||||
field_meta_data* core_sqlsrv_field_metadata( _Inout_ sqlsrv_stmt* stmt, _In_ SQLSMALLINT colno TSRMLS_DC );
|
||||
|
|
|
@ -342,7 +342,7 @@ sqlsrv_stmt* core_sqlsrv_create_stmt( _Inout_ sqlsrv_conn* conn, _In_ driver_stm
|
|||
// The sql type is given as a hint if the driver provides it.
|
||||
|
||||
void core_sqlsrv_bind_param( _Inout_ sqlsrv_stmt* stmt, _In_ SQLUSMALLINT param_num, _In_ SQLSMALLINT direction, _Inout_ zval* param_z,
|
||||
_In_ SQLSRV_PHPTYPE php_out_type, _In_ SQLSRV_ENCODING encoding, _Inout_ SQLSMALLINT sql_type, _Inout_ SQLULEN column_size,
|
||||
_In_ SQLSRV_PHPTYPE php_out_type, _Inout_ SQLSRV_ENCODING encoding, _Inout_ SQLSMALLINT sql_type, _Inout_ SQLULEN column_size,
|
||||
_Inout_ SQLSMALLINT decimal_digits TSRMLS_DC )
|
||||
{
|
||||
SQLSMALLINT c_type;
|
||||
|
@ -373,7 +373,7 @@ void core_sqlsrv_bind_param( _Inout_ sqlsrv_stmt* stmt, _In_ SQLUSMALLINT param_
|
|||
}
|
||||
bool zval_was_null = ( Z_TYPE_P( param_z ) == IS_NULL );
|
||||
bool zval_was_bool = ( Z_TYPE_P( param_z ) == IS_TRUE || Z_TYPE_P( param_z ) == IS_FALSE );
|
||||
bool zval_was_long = ( Z_TYPE_P( param_z ) == IS_LONG && php_out_type == SQLSRV_PHPTYPE_INT );
|
||||
bool zval_was_long = ( Z_TYPE_P( param_z ) == IS_LONG && php_out_type == SQLSRV_PHPTYPE_INT && (sql_type == SQL_BIGINT || sql_type == SQL_UNKNOWN_TYPE ));
|
||||
// if the user asks for for a specific type for input and output, make sure the data type we send matches the data we
|
||||
// type we expect back, since we can only send and receive the same type. Anything can be converted to a string, so
|
||||
// we always let that match if they want a string back.
|
||||
|
@ -386,6 +386,7 @@ void core_sqlsrv_bind_param( _Inout_ sqlsrv_stmt* stmt, _In_ SQLUSMALLINT param_
|
|||
}
|
||||
if( zval_was_long ){
|
||||
convert_to_string( param_z );
|
||||
encoding = SQLSRV_ENCODING_SYSTEM;
|
||||
match = Z_TYPE_P( param_z ) == IS_STRING;
|
||||
}
|
||||
else {
|
||||
|
@ -424,6 +425,7 @@ void core_sqlsrv_bind_param( _Inout_ sqlsrv_stmt* stmt, _In_ SQLUSMALLINT param_
|
|||
case SQLSRV_PHPTYPE_INT:
|
||||
if( zval_was_long ){
|
||||
convert_to_string( param_z );
|
||||
encoding = SQLSRV_ENCODING_SYSTEM;
|
||||
}
|
||||
else {
|
||||
convert_to_long( param_z );
|
||||
|
|
|
@ -69,14 +69,14 @@ unset($stmt);
|
|||
unset($conn);
|
||||
?>
|
||||
--EXPECT--
|
||||
Large bigint output:
|
||||
Large bigint output:
|
||||
string(18) "922337203685479936"
|
||||
|
||||
Large bigint inout:
|
||||
Large bigint inout:
|
||||
string(18) "922337203685479936"
|
||||
|
||||
Small bigint output:
|
||||
int(922337203)
|
||||
|
||||
Small bigint inout:
|
||||
Small bigint output:
|
||||
int(922337203)
|
||||
|
||||
Small bigint inout:
|
||||
int(922337203)
|
||||
|
|
|
@ -69,14 +69,14 @@ unset($stmt);
|
|||
unset($conn);
|
||||
?>
|
||||
--EXPECT--
|
||||
True bool output:
|
||||
True bool output:
|
||||
int(1)
|
||||
|
||||
True bool inout:
|
||||
True bool inout:
|
||||
int(1)
|
||||
|
||||
True bool output:
|
||||
True bool output:
|
||||
int(0)
|
||||
|
||||
True bool inout:
|
||||
True bool inout:
|
||||
int(0)
|
||||
|
|
|
@ -328,6 +328,7 @@ function connect($options = array(), $disableCE = false)
|
|||
*/
|
||||
function createTable($conn, $tbname, $columnMetaArr)
|
||||
{
|
||||
require_once("MsCommon.inc");
|
||||
dropTable($conn, $tbname);
|
||||
$colDef = "";
|
||||
foreach ($columnMetaArr as $meta) {
|
||||
|
|
|
@ -66,14 +66,14 @@ sqlsrv_close($conn);
|
|||
|
||||
?>
|
||||
--EXPECT--
|
||||
Large bigint output:
|
||||
Large bigint output:
|
||||
string(18) "922337203685479936"
|
||||
|
||||
Large bigint inout:
|
||||
Large bigint inout:
|
||||
string(18) "922337203685479936"
|
||||
|
||||
Small bigint output:
|
||||
int(922337203)
|
||||
|
||||
Small bigint inout:
|
||||
Small bigint output:
|
||||
int(922337203)
|
||||
|
||||
Small bigint inout:
|
||||
int(922337203)
|
||||
|
|
|
@ -66,14 +66,14 @@ sqlsrv_close($conn);
|
|||
|
||||
?>
|
||||
--EXPECT--
|
||||
True bool output:
|
||||
True bool output:
|
||||
bool(true)
|
||||
|
||||
True bool inout:
|
||||
True bool inout:
|
||||
bool(true)
|
||||
|
||||
False bool output:
|
||||
False bool output:
|
||||
bool(false)
|
||||
|
||||
False bool inout:
|
||||
False bool inout:
|
||||
bool(false)
|
||||
|
|
Loading…
Reference in a new issue