-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Selecting Timestamp Column Causes Encoding Issues #553
Comments
Hi @laclemen the SQL Server data type
|
@david-puglielli no I am not trying to insert timestamps in our prod code. That was just to provide a sample script. We have a timestamp/rowversion column on all tables for tracking purposes. I am unable to do a select * from any table due to this encoding issue. We just upgraded from release 4.1.7 to 4.1.8 in order to take advantage of the Connection Resiliency settings and upon upgrading I am no longer able to select a column of type timestamp. I also tried using 4.3.0 with no luck. This seems to have been supported in previous releases. |
Okay, I see. Could you provide us with some expected output for the script above? It would be useful to know what you were seeing before the behaviour changed so we can verify if this is a regression. Thanks! |
@laclemen If you are trying to recover the hex representation of a timestamp value, then you can use the PHP function bin2hex() for any field containing binary data. For example, try this in the script above:
Output:
|
Hi @laclemen what you saw was actually a result of a fix to Issue #270 (by PR #297) earlier this year for 4.1.7-preview release Since then, for data from binary fields we will now display binary values instead of hex. You can use bin2hex() as suggested by @david-puglielli above. |
Hi @laclemen I just want to know if we have answered your questions. Thanks! |
@laclemen closing this issue due to inactivity, feel free to reopen the issue 😃 |
Below is my sample php script I am using to reproduce the issue. I created a tempTable with an int and timestamp column. Then I loop through and insert 5 values and attempt to select * from the table. When selecting however, the result is not correct. Executing it from the command line I get the following.
Array
(
[0] => Array
(
[EventId] => 1
[0] => 1
[RowTS] =>
[1] =>
)
).
In my error logs the array is immediately broken upon the first RowTS in the array.
[25-Sep-2017 10:57:35 CST6CDT] Array
(
[0] => Array
(
[EventId] => 1
[0] => 1
[RowTS] =>
`<?php
try
{
$uid = '';
$pwd = '';
$conn = new PDO("sqlsrv:server = localhost ; Database = testDb ; ConnectRetryCount = 6; ConnectRetryInterval = 10;", $uid, $pwd);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch( PDOException $e )
{
echo "Could not connect.\n";
print_r( $e->getMessage() );
}
try
{
$stmt = $conn->query("IF OBJECT_ID('testDb.dbo.tempTable', 'U') IS NOT NULL DROP TABLE testDb.dbo.tempTable");
$stmt = $conn->query("create table tempTable (EventId int, RowTS TIMESTAMP)");
}
catch( PDOException $e )
{
print_r($e->getTraceAsString());
}`
The text was updated successfully, but these errors were encountered: