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,
|
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 );
|
_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,
|
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 );
|
_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 );
|
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 );
|
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.
|
// 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,
|
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 )
|
_Inout_ SQLSMALLINT decimal_digits TSRMLS_DC )
|
||||||
{
|
{
|
||||||
SQLSMALLINT c_type;
|
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_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_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
|
// 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
|
// 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.
|
// 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 ){
|
if( zval_was_long ){
|
||||||
convert_to_string( param_z );
|
convert_to_string( param_z );
|
||||||
|
encoding = SQLSRV_ENCODING_SYSTEM;
|
||||||
match = Z_TYPE_P( param_z ) == IS_STRING;
|
match = Z_TYPE_P( param_z ) == IS_STRING;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -424,6 +425,7 @@ void core_sqlsrv_bind_param( _Inout_ sqlsrv_stmt* stmt, _In_ SQLUSMALLINT param_
|
||||||
case SQLSRV_PHPTYPE_INT:
|
case SQLSRV_PHPTYPE_INT:
|
||||||
if( zval_was_long ){
|
if( zval_was_long ){
|
||||||
convert_to_string( param_z );
|
convert_to_string( param_z );
|
||||||
|
encoding = SQLSRV_ENCODING_SYSTEM;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
convert_to_long( param_z );
|
convert_to_long( param_z );
|
||||||
|
|
|
@ -69,14 +69,14 @@ unset($stmt);
|
||||||
unset($conn);
|
unset($conn);
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
Large bigint output:
|
Large bigint output:
|
||||||
string(18) "922337203685479936"
|
string(18) "922337203685479936"
|
||||||
|
|
||||||
Large bigint inout:
|
Large bigint inout:
|
||||||
string(18) "922337203685479936"
|
string(18) "922337203685479936"
|
||||||
|
|
||||||
Small bigint output:
|
Small bigint output:
|
||||||
int(922337203)
|
int(922337203)
|
||||||
|
|
||||||
Small bigint inout:
|
Small bigint inout:
|
||||||
int(922337203)
|
int(922337203)
|
||||||
|
|
|
@ -69,14 +69,14 @@ unset($stmt);
|
||||||
unset($conn);
|
unset($conn);
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
True bool output:
|
True bool output:
|
||||||
int(1)
|
int(1)
|
||||||
|
|
||||||
True bool inout:
|
True bool inout:
|
||||||
int(1)
|
int(1)
|
||||||
|
|
||||||
True bool output:
|
True bool output:
|
||||||
int(0)
|
int(0)
|
||||||
|
|
||||||
True bool inout:
|
True bool inout:
|
||||||
int(0)
|
int(0)
|
||||||
|
|
|
@ -328,6 +328,7 @@ function connect($options = array(), $disableCE = false)
|
||||||
*/
|
*/
|
||||||
function createTable($conn, $tbname, $columnMetaArr)
|
function createTable($conn, $tbname, $columnMetaArr)
|
||||||
{
|
{
|
||||||
|
require_once("MsCommon.inc");
|
||||||
dropTable($conn, $tbname);
|
dropTable($conn, $tbname);
|
||||||
$colDef = "";
|
$colDef = "";
|
||||||
foreach ($columnMetaArr as $meta) {
|
foreach ($columnMetaArr as $meta) {
|
||||||
|
|
|
@ -66,14 +66,14 @@ sqlsrv_close($conn);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
Large bigint output:
|
Large bigint output:
|
||||||
string(18) "922337203685479936"
|
string(18) "922337203685479936"
|
||||||
|
|
||||||
Large bigint inout:
|
Large bigint inout:
|
||||||
string(18) "922337203685479936"
|
string(18) "922337203685479936"
|
||||||
|
|
||||||
Small bigint output:
|
Small bigint output:
|
||||||
int(922337203)
|
int(922337203)
|
||||||
|
|
||||||
Small bigint inout:
|
Small bigint inout:
|
||||||
int(922337203)
|
int(922337203)
|
||||||
|
|
|
@ -66,14 +66,14 @@ sqlsrv_close($conn);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
True bool output:
|
True bool output:
|
||||||
bool(true)
|
bool(true)
|
||||||
|
|
||||||
True bool inout:
|
True bool inout:
|
||||||
bool(true)
|
bool(true)
|
||||||
|
|
||||||
False bool output:
|
False bool output:
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
False bool inout:
|
False bool inout:
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
Loading…
Reference in a new issue